Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fee6befb
提交
fee6befb
authored
10月 01, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
IncSubtensor: generalized the allocation of the output view
上级
9728b350
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
32 行增加
和
9 行删除
+32
-9
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+4
-0
cuda_ndarray.cuh
theano/sandbox/cuda/cuda_ndarray.cuh
+4
-0
basic.py
theano/tensor/basic.py
+24
-9
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
fee6befb
...
...
@@ -2433,6 +2433,10 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
def
copy_of_x
(
self
,
x
):
return
"""(CudaNdarray*) CudaNdarray_Copy(
%(x)
s)"""
%
locals
()
def
make_view_buffer
(
self
,
x
,
view_ndim
):
return
"""CudaNdarray* xview = (CudaNdarray*)
CudaNdarray_New(
%(view_ndim)
s)"""
%
locals
()
def
c_code_cache_version
(
self
):
# TODO: cooperate with parent class' C code
return
()
...
...
theano/sandbox/cuda/cuda_ndarray.cuh
浏览文件 @
fee6befb
...
...
@@ -439,6 +439,10 @@ CudaNdarray_TakeFrom(CudaNdarray * self, PyObject *args);
static
int
fprint_CudaNdarray
(
FILE
*
fd
,
const
CudaNdarray
*
self
);
PyObject
*
CudaNdarray_View
(
const
CudaNdarray
*
self
);
#endif
/*
Local Variables:
...
...
theano/tensor/basic.py
浏览文件 @
fee6befb
...
...
@@ -4575,20 +4575,14 @@ class IncSubtensor(Op):
%(z)
s =
%(copy_of_x)
s; }
"""
%
locals
()
alloc_view_of_z
=
self
.
make_view_buffer
(
z
,
view_ndim
)
#Make a first view on the output, as we will write into it.
build_view
=
"""
//TODO: give this Op a second output so that this view can be cached
//TODO: alternatively, fix the memory leak on failure
Py_INCREF(PyArray_DESCR(
%(z)
s));
PyArrayObject * xview = (PyArrayObject*)PyArray_NewFromDescr(
&PyArray_Type,
PyArray_DESCR(
%(z)
s),
%(view_ndim)
s,
PyArray_DIMS(
%(z)
s),
PyArray_STRIDES(
%(z)
s),
PyArray_DATA(
%(z)
s),
%(z)
s->flags,
NULL);
%(alloc_view_of_z)
s;
if (!xview)
{
%(fail)
s;
...
...
@@ -4670,6 +4664,27 @@ class IncSubtensor(Op):
return
"""(PyArrayObject*)PyArray_FromAny(py_
%(x)
s, NULL, 0, 0,
NPY_ARRAY_ENSURECOPY, NULL)"""
%
locals
()
def
make_view_buffer
(
x
,
view_ndim
):
"""
x: a string identifying an array to be viewed
view_ndim: a string specifying the number of dimensions
to have in the view
This doesn't need to actually set up the view with the
right indexing; we'll do that manually later.
"""
return
"""PyArrayObject * xview =
(PyArrayObject*)PyArray_NewFromDescr(
&PyArray_Type,
PyArray_DESCR(
%(x)
s),
%(view_ndim)
s,
PyArray_DIMS(
%(x)
s),
PyArray_STRIDES(
%(x)
s),
PyArray_DATA(
%(x)
s),
%(x)
s->flags,
NULL)"""
%
locals
()
def
infer_shape
(
self
,
node
,
shapes
):
return
[
shapes
[
0
]]
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论