Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
66f23bc6
提交
66f23bc6
authored
10月 01, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
made copying the input work on both CPU and GPU
上级
3bd3ae11
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
3 行删除
+28
-3
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+3
-0
basic.py
theano/tensor/basic.py
+25
-3
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
66f23bc6
...
@@ -2419,6 +2419,9 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
...
@@ -2419,6 +2419,9 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
rval
=
tensor
.
IncSubtensor
.
make_node
(
self
,
x
,
y
,
*
inputs
)
rval
=
tensor
.
IncSubtensor
.
make_node
(
self
,
x
,
y
,
*
inputs
)
return
Apply
(
self
,
[
x
,
y
]
+
rval
.
inputs
[
2
:],
[
x
.
type
()])
return
Apply
(
self
,
[
x
,
y
]
+
rval
.
inputs
[
2
:],
[
x
.
type
()])
def
copy_of_x
(
self
,
x
):
return
"""(CudaNdarray*) CudaNdarray_Copy(
%(x)
s)"""
%
locals
()
class
GpuFlatten
(
tensor
.
Flatten
,
GpuOp
):
class
GpuFlatten
(
tensor
.
Flatten
,
GpuOp
):
"""
"""
...
...
theano/tensor/basic.py
浏览文件 @
66f23bc6
...
@@ -4554,6 +4554,9 @@ class IncSubtensor(Op):
...
@@ -4554,6 +4554,9 @@ class IncSubtensor(Op):
view_ndim
=
(
node
.
inputs
[
0
]
.
ndim
-
view_ndim
=
(
node
.
inputs
[
0
]
.
ndim
-
numpy
.
sum
([
not
isinstance
(
idx
,
slice
)
numpy
.
sum
([
not
isinstance
(
idx
,
slice
)
for
idx
in
self
.
idx_list
]))
for
idx
in
self
.
idx_list
]))
copy_of_x
=
self
.
copy_of_x
(
x
)
copy_input_if_necessary
=
"""
copy_input_if_necessary
=
"""
if (
%(inplace)
s)
if (
%(inplace)
s)
{
{
...
@@ -4567,9 +4570,7 @@ class IncSubtensor(Op):
...
@@ -4567,9 +4570,7 @@ class IncSubtensor(Op):
else
else
{
{
if (
%(z)
s) Py_DECREF(
%(z)
s);
if (
%(z)
s) Py_DECREF(
%(z)
s);
%(z)
s = (PyArrayObject*)PyArray_FromAny(py_
%(x)
s, NULL, 0, 0,
%(z)
s =
%(copy_of_x)
s; }
NPY_ARRAY_ENSURECOPY, NULL);
}
"""
%
locals
()
"""
%
locals
()
#Make a first view on the output, as we will write into it.
#Make a first view on the output, as we will write into it.
...
@@ -4637,6 +4638,27 @@ class IncSubtensor(Op):
...
@@ -4637,6 +4638,27 @@ class IncSubtensor(Op):
else
:
else
:
return
()
return
()
def
copy_of_x
(
self
,
x
):
"""
x: a string giving the name of a C variable pointing to an array
Returns C code expression to make a copy of x.
Base class uses PyArrayObject *, subclasses may override for
different types of arrays.
"""
# Parameters of PyArrary_FromAny are:
# array
# dtype: we pass NULL to say any dtype is acceptable, so the existing
# dtype will be copied
# min_depth: we pass 0 to have this parameter ignored
# max_depth: we pass 0 to have this parameter ignored
# requirements: here we pass NPY_ARRAY_ENSURECOPY to force a copy
# context: this is almost always NULL, I'm not sure what it's used for
return
"""(PyArrayObject*)PyArray_FromAny(py_
%(x)
s, NULL, 0, 0,
NPY_ARRAY_ENSURECOPY, NULL)"""
%
locals
()
def
infer_shape
(
self
,
node
,
shapes
):
def
infer_shape
(
self
,
node
,
shapes
):
return
[
shapes
[
0
]]
return
[
shapes
[
0
]]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论