Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
83bf7251
提交
83bf7251
authored
3月 23, 2013
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PEP8
上级
5ff97962
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
21 行增加
和
13 行删除
+21
-13
basic.py
theano/tensor/basic.py
+21
-13
没有找到文件。
theano/tensor/basic.py
浏览文件 @
83bf7251
...
...
@@ -4250,8 +4250,8 @@ def get_canonical_form_slice(theslice, length):
that respects the conventions imposed by python and numpy.
In a canonical form a slice is represented by a canonical form slice,
in which 0 <= start <= stop <= length and step > 0, and a flag which says
if
the resulting set of numbers needs to be reversed or not.
in which 0 <= start <= stop <= length and step > 0, and a flag which says
if
the resulting set of numbers needs to be reversed or not.
'''
if
isinstance
(
theslice
,
slice
):
...
...
@@ -4292,8 +4292,8 @@ def get_canonical_form_slice(theslice, length):
# Full slice.
return
slice
(
0
,
length
,
1
),
1
if
is_stop_constant
and
stop
>=
0
:
return
(
slice
(
0
,
switch
(
lt
(
stop
,
length
),
stop
,
length
),
1
),
1
)
return
(
slice
(
0
,
switch
(
lt
(
stop
,
length
),
stop
,
length
),
1
),
1
)
stop_plus_len
=
stop
+
length
stop
=
switch
(
lt
(
stop
,
0
),
...
...
@@ -4343,6 +4343,7 @@ def get_canonical_form_slice(theslice, length):
sgn_step
=
-
1
else
:
is_step_neg
=
lt
(
step
,
0
)
def
switch_neg_step
(
a
,
b
):
return
switch
(
is_step_neg
,
a
,
b
)
abs_step
=
abs
(
step
)
...
...
@@ -7120,7 +7121,8 @@ class AdvancedSubtensor1(Op):
// if all values fit.
if (!PyArray_CanCastSafely(i_type, NPY_INTP)) {
npy_int64 min_val, max_val;
PyObject* py_min_val = PyArray_Min(
%(i_name)
s, NPY_MAXDIMS, NULL);
PyObject* py_min_val = PyArray_Min(
%(i_name)
s, NPY_MAXDIMS,
NULL);
if (py_min_val == NULL) {
%(fail)
s;
}
...
...
@@ -7129,7 +7131,8 @@ class AdvancedSubtensor1(Op):
if (min_val == -1 && PyErr_Occurred()) {
%(fail)
s;
}
PyObject* py_max_val = PyArray_Max(
%(i_name)
s, NPY_MAXDIMS, NULL);
PyObject* py_max_val = PyArray_Max(
%(i_name)
s, NPY_MAXDIMS,
NULL);
if (py_max_val == NULL) {
%(fail)
s;
}
...
...
@@ -7139,7 +7142,8 @@ class AdvancedSubtensor1(Op):
%(fail)
s;
}
if (min_val < NPY_MIN_INTP || max_val > NPY_MAX_INTP) {
PyErr_SetString(PyExc_IndexError, "Index contains values "
PyErr_SetString(PyExc_IndexError,
"Index contains values "
"that are bigger than the maximum array "
"size on this system.");
%(fail)
s;
...
...
@@ -7170,7 +7174,8 @@ class AdvancedSubtensor1(Op):
}
if (
%(output_name)
s != NULL) {
for (; i < nd; i++) {
if (shape[i] != PyArray_DIMS(
%(a_name)
s)[i-PyArray_NDIM(indices)+1]) {
if (shape[i] != PyArray_DIMS(
%(a_name)
s)[
i-PyArray_NDIM(indices)+1]) {
Py_CLEAR(
%(output_name)
s);
break;
}
...
...
@@ -7178,8 +7183,8 @@ class AdvancedSubtensor1(Op):
}
}
}
%(output_name)
s = (PyArrayObject*)PyArray_TakeFrom(
%(a_name)
s, indices, 0,
%(output_name)
s, NPY_RAISE);
%(output_name)
s = (PyArrayObject*)PyArray_TakeFrom(
%(a_name)
s, indices, 0,
%(output_name)
s, NPY_RAISE);
Py_DECREF(indices);
if (
%(output_name)
s == NULL)
%(fail)
s;
"""
%
locals
()
...
...
@@ -7189,6 +7194,7 @@ class AdvancedSubtensor1(Op):
advanced_subtensor1
=
AdvancedSubtensor1
()
class
AdvancedIncSubtensor1
(
Op
):
"""Increments a subtensor using advanced slicing (list of index)"""
def
__init__
(
self
,
inplace
=
False
,
set_instead_of_inc
=
False
):
...
...
@@ -7252,10 +7258,10 @@ class AdvancedIncSubtensor1(Op):
x
[
idx
]
=
y
else
:
increment
=
inplace_increment
if
increment
is
None
:
if
increment
is
None
:
increment
=
self
.
inplace_increment1d_slow
increment
(
x
,
idx
,
y
)
increment
(
x
,
idx
,
y
)
out
[
0
]
=
x
...
...
@@ -7298,7 +7304,8 @@ class AdvancedIncSubtensor1(Op):
return
[
gx
,
gy
]
+
[
DisconnectedType
()()]
*
len
(
idx_list
)
advanced_inc_subtensor1
=
AdvancedIncSubtensor1
()
def
as_index_variable
(
idx
):
if
idx
is
None
:
return
NoneConst
...
...
@@ -7358,6 +7365,7 @@ class SliceType(gof.Type):
slicetype
=
SliceType
()
class
NoneTypeT
(
gof
.
Type
):
def
filter
(
self
,
x
,
strict
=
False
,
allow_downcast
=
None
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论