Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e6b53352
提交
e6b53352
authored
9月 19, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Now GpuSubtensor have c code by reusing the Subtensor helper c code generator.
上级
529f4421
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
62 行增加
和
1 行删除
+62
-1
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+54
-1
cuda_ndarray.cuh
theano/sandbox/cuda/cuda_ndarray.cuh
+8
-0
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
e6b53352
...
...
@@ -1911,7 +1911,7 @@ class GpuReshape(tensor.Reshape, GpuOp):
out
[
0
]
=
x
.
reshape
(
tuple
(
shp
))
class
GpuSubtensor
(
tensor
.
Subtensor
,
GpuOp
):
class
GpuSubtensor
(
GpuOp
,
tensor
.
Subtensor
):
"""
Implement subtensor on the gpu.
"""
...
...
@@ -1952,6 +1952,59 @@ class GpuSubtensor(tensor.Subtensor, GpuOp):
cdata
=
cdata
[
0
]
out
[
0
]
=
x
.
__getitem__
(
cdata
)
def
c_code
(
self
,
node
,
name
,
inputs
,
outputs
,
sub
):
x
=
inputs
[
0
]
z
,
=
outputs
view_ndim
=
node
.
outputs
[
0
]
.
ndim
fail
=
sub
[
'fail'
]
build_view
=
"""
//TODO: give this Op a second output so that this view can be cached
//TODO: alternatively, fix the memory leak on failure
CudaNdarray* xview = (CudaNdarray*) CudaNdarray_New(
%(view_ndim)
s);
if (!xview)
{
%(fail)
s;
}
if (CudaNdarray_set_device_data(xview, CudaNdarray_DEV_DATA(
%(x)
s),
(PyObject*) NULL))
{
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set the"
" devdata field of the view");
Py_XDECREF(xview);
%(fail)
s;
}
cnda_mark_dev_structure_dirty(xview);
#define CudaNdarray_set_device_data2(obj, ptr, base)
\
CudaNdarray_set_device_data(obj, (float *)ptr, base)
"""
%
locals
()
get_xview
=
self
.
helper_c_code
(
node
,
name
,
inputs
,
outputs
,
sub
,
self
.
idx_list
,
c_prefix
=
'CudaNdarray'
,
set_data
=
'CudaNdarray_set_device_data2'
,
set_dim
=
'CudaNdarray_set_dim'
,
set_stride
=
'CudaNdarray_set_stride'
,
update_flags
=
""
,
strides_mul
=
4
)
finish_view
=
"""
//Set the base only now
if(CudaNdarray_set_device_data(xview, CudaNdarray_DEV_DATA(xview),
%(x)
s)){
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set"
" the base of the view array");
Py_XDECREF(xview);
%(fail)
s;
}
Py_XDECREF(
%(z)
s);
%(z)
s = xview;
"""
%
locals
()
return
build_view
+
"{"
+
get_xview
+
"}"
+
finish_view
class
GpuAdvancedSubtensor1
(
tensor
.
AdvancedSubtensor1
,
GpuOp
):
"""
...
...
theano/sandbox/cuda/cuda_ndarray.cuh
浏览文件 @
e6b53352
...
...
@@ -161,6 +161,14 @@ DllExport const int *CudaNdarray_DEV_STRIDES(const CudaNdarray * self);
DllExport
const
int
*
CudaNdarray_DEV_LOG2DIMS
(
const
CudaNdarray
*
self
);
DllExport
float
*
CudaNdarray_DEV_DATA
(
const
CudaNdarray
*
self
);
// The following 4 macro are here to help make c code generator that work on
// both PyArray and CudaNdarray. This is at least used for Subtensor and
// GpuSubtensor
#define CudaNdarray_DIMS CudaNdarray_HOST_DIMS
#define CudaNdarray_NDIM(self) self->nd
#define CudaNdarray_STRIDES CudaNdarray_HOST_STRIDES
#define CudaNdarray_BYTES CudaNdarray_DEV_DATA
/**
* Return the number of elements in the ndarray (product of the dimensions)
*/
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论