Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
4abf0081
提交
4abf0081
authored
4月 27, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2832 from nouiz/tests
[TESTS] Fix crash in tests in debugmode and small optimizations.
上级
ba67b348
fe15e2f1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
25 行删除
+26
-25
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+19
-22
subtensor.py
theano/sandbox/gpuarray/subtensor.py
+2
-1
subtensor.py
theano/tensor/subtensor.py
+5
-2
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
4abf0081
...
@@ -2604,14 +2604,16 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2604,14 +2604,16 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
out
,
=
out_
out
,
=
out_
if
not
self
.
inplace
:
if
not
self
.
inplace
:
x
=
x
.
copy
()
x
=
x
.
copy
()
assert
y
.
ndim
<=
x
.
ndim
# Should be guaranteed by `make_node`
if
self
.
set_instead_of_inc
:
if
self
.
set_instead_of_inc
:
# CudaNdarray __setitem__ doesn't do broadcast nor support
# CudaNdarray __setitem__ doesn't do broadcast nor support
# list of index.
# list of index.
assert
y
.
ndim
<=
x
.
ndim
# Should be guaranteed by `make_node`
if
y
.
ndim
==
x
.
ndim
:
if
y
.
ndim
==
x
.
ndim
:
assert
len
(
y
)
==
len
(
idx
)
assert
len
(
y
)
==
len
(
idx
)
for
(
j
,
i
)
in
enumerate
(
idx
):
j
=
0
for
i
in
idx
:
x
[
i
]
=
y
[
j
]
x
[
i
]
=
y
[
j
]
j
+=
1
else
:
else
:
for
i
in
idx
:
for
i
in
idx
:
x
[
i
]
=
y
x
[
i
]
=
y
...
@@ -2619,18 +2621,25 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2619,18 +2621,25 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
# If `y` has as many dimensions as `x`, then we want to iterate
# If `y` has as many dimensions as `x`, then we want to iterate
# jointly on `x` and `y`. Otherwise, it means `y` should be
# jointly on `x` and `y`. Otherwise, it means `y` should be
# broadcasted to fill all relevant rows of `x`.
# broadcasted to fill all relevant rows of `x`.
assert
y
.
ndim
<=
x
.
ndim
# Should be guaranteed by `make_node`
if
y
.
ndim
==
x
.
ndim
:
if
y
.
ndim
==
x
.
ndim
:
assert
len
(
y
)
==
len
(
idx
)
if
len
(
y
)
==
1
:
for
(
j
,
i
)
in
enumerate
(
idx
):
# Allow broadcasting of y[0]
x
[
i
]
+=
y
[
j
]
y_0
=
y
[
0
]
for
i
in
idx
:
x
[
i
]
+=
y_0
else
:
assert
len
(
y
)
==
len
(
idx
)
j
=
0
for
i
in
idx
:
x
[
i
]
+=
y
[
j
]
j
+=
1
else
:
else
:
for
i
in
idx
:
for
i
in
idx
:
x
[
i
]
+=
y
x
[
i
]
+=
y
out
[
0
]
=
x
out
[
0
]
=
x
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
return
(
3
,)
return
(
4
,)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
if
(
self
.
set_instead_of_inc
)
or
\
if
(
self
.
set_instead_of_inc
)
or
\
...
@@ -2645,7 +2654,7 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2645,7 +2654,7 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
inplace
=
int
(
self
.
inplace
)
inplace
=
int
(
self
.
inplace
)
return
"""
return
"""
PyObject *
x_obj, *y_obj, *
row_x, *row_y;
PyObject *row_x, *row_y;
PyObject *x_rowind_obj, *y_rowind_obj;
PyObject *x_rowind_obj, *y_rowind_obj;
dtype_
%(ind)
s *p_index;
dtype_
%(ind)
s *p_index;
int num_indices, j;
int num_indices, j;
...
@@ -2666,9 +2675,6 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2666,9 +2675,6 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
Py_XINCREF(
%(out)
s);
Py_XINCREF(
%(out)
s);
}
}
x_obj = (PyObject*)CudaNdarray_View(
%(out)
s);
y_obj = (PyObject*)CudaNdarray_View(
%(y)
s);
for (j = 0;j < num_indices; j++) {
for (j = 0;j < num_indices; j++) {
p_index = (dtype_
%(ind)
s *)PyArray_GETPTR1(
%(ind)
s, j);
p_index = (dtype_
%(ind)
s *)PyArray_GETPTR1(
%(ind)
s, j);
...
@@ -2681,23 +2687,18 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2681,23 +2687,18 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
// Dec Ref what ever we have increfed or allocated so far
// Dec Ref what ever we have increfed or allocated so far
// We deallocate objects exactly in the reverse order they were allocated.
// We deallocate objects exactly in the reverse order they were allocated.
Py_XDECREF(x_rowind_obj);
Py_XDECREF(x_rowind_obj);
Py_XDECREF(y_obj);
Py_XDECREF(x_obj);
%(fail)
s;
%(fail)
s;
}
}
y_rowind_obj = PyInt_FromLong(j);
y_rowind_obj = PyInt_FromLong(j);
row_x = CudaNdarray_Subscript((PyObject*)
%(out)
s, x_rowind_obj);
row_x = CudaNdarray_Subscript(x_obj, x_rowind_obj);
row_y = CudaNdarray_Subscript(py_
%(y)
s, y_rowind_obj);
row_y = CudaNdarray_Subscript(y_obj, y_rowind_obj);
if ((row_x == NULL) || (row_y == NULL)) {
if ((row_x == NULL) || (row_y == NULL)) {
Py_XDECREF(row_y);
Py_XDECREF(row_y);
Py_XDECREF(row_x);
Py_XDECREF(row_x);
Py_XDECREF(y_rowind_obj);
Py_XDECREF(y_rowind_obj);
Py_XDECREF(x_rowind_obj);
Py_XDECREF(x_rowind_obj);
Py_XDECREF(y_obj);
Py_XDECREF(x_obj);
%(fail)
s;
%(fail)
s;
}
}
...
@@ -2707,8 +2708,6 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2707,8 +2708,6 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
Py_XDECREF(row_x);
Py_XDECREF(row_x);
Py_XDECREF(y_rowind_obj);
Py_XDECREF(y_rowind_obj);
Py_XDECREF(x_rowind_obj);
Py_XDECREF(x_rowind_obj);
Py_XDECREF(y_obj);
Py_XDECREF(x_obj);
%(fail)
s;
%(fail)
s;
}
}
...
@@ -2718,8 +2717,6 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
...
@@ -2718,8 +2717,6 @@ class GpuAdvancedIncSubtensor1(tensor.AdvancedIncSubtensor1, GpuOp):
Py_XDECREF(x_rowind_obj);
Py_XDECREF(x_rowind_obj);
}
}
Py_XDECREF(y_obj);
Py_XDECREF(x_obj);
if (!
%(out)
s) {
if (!
%(out)
s) {
%(fail)
s
%(fail)
s
...
...
theano/sandbox/gpuarray/subtensor.py
浏览文件 @
4abf0081
...
@@ -427,7 +427,8 @@ class GpuAdvancedIncSubtensor1(HideC, tensor.AdvancedIncSubtensor1):
...
@@ -427,7 +427,8 @@ class GpuAdvancedIncSubtensor1(HideC, tensor.AdvancedIncSubtensor1):
if
len
(
idx
)
==
0
:
if
len
(
idx
)
==
0
:
pass
pass
elif
y
.
ndim
==
x
.
ndim
:
# if len(y) == 1, we need to broadcast it.
elif
y
.
ndim
==
x
.
ndim
and
len
(
y
)
!=
1
:
assert
len
(
y
)
==
len
(
idx
)
assert
len
(
y
)
==
len
(
idx
)
k
=
self
.
getInplElemwiseAdditionKernel
(
x
[
0
],
y
[
0
])
k
=
self
.
getInplElemwiseAdditionKernel
(
x
[
0
],
y
[
0
])
...
...
theano/tensor/subtensor.py
浏览文件 @
4abf0081
...
@@ -1923,12 +1923,15 @@ class AdvancedIncSubtensor1(Op):
...
@@ -1923,12 +1923,15 @@ class AdvancedIncSubtensor1(Op):
if
y
.
ndim
==
x
.
ndim
:
if
y
.
ndim
==
x
.
ndim
:
if
len
(
y
)
==
1
:
if
len
(
y
)
==
1
:
# Allow broadcasting of y[0]
# Allow broadcasting of y[0]
y_0
=
y
[
0
]
for
i
in
idx
:
for
i
in
idx
:
x
[
i
]
+=
y
[
0
]
x
[
i
]
+=
y
_0
else
:
else
:
assert
len
(
y
)
==
len
(
idx
)
assert
len
(
y
)
==
len
(
idx
)
for
(
j
,
i
)
in
enumerate
(
idx
):
j
=
0
for
i
in
idx
:
x
[
i
]
+=
y
[
j
]
x
[
i
]
+=
y
[
j
]
j
+=
1
else
:
else
:
for
i
in
idx
:
for
i
in
idx
:
x
[
i
]
+=
y
x
[
i
]
+=
y
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论