Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5fe90b3d
提交
5fe90b3d
authored
10月 02, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
renamed xview to zview since it is a view of z, not x
上级
cf8fd44e
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
39 行增加
和
30 行删除
+39
-30
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+9
-9
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+30
-21
basic.py
theano/tensor/basic.py
+0
-0
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
5fe90b3d
...
...
@@ -2457,7 +2457,7 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
This doesn't need to actually set up the view with the
right indexing; we'll do that manually later.
"""
return
"""CudaNdarray*
x
view = (CudaNdarray*)
return
"""CudaNdarray*
z
view = (CudaNdarray*)
CudaNdarray_New(
%(view_ndim)
s)"""
%
locals
()
def
get_helper_c_code_args
(
self
):
...
...
@@ -2487,41 +2487,41 @@ class GpuIncSubtensor(tensor.IncSubtensor, GpuOp):
def
link_view_array
(
self
,
x
,
fail
):
return
"""
if (CudaNdarray_set_device_data(
x
view, CudaNdarray_DEV_DATA(
%(x)
s),
if (CudaNdarray_set_device_data(
z
view, 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(
x
view);
Py_XDECREF(
z
view);
%(fail)
s;
}
cnda_mark_dev_structure_dirty(
x
view);
cnda_mark_dev_structure_dirty(
z
view);
"""
%
locals
()
def
set_view_base
(
self
,
x
,
fail
):
return
"""
//Set the base only now
if(CudaNdarray_set_device_data(
xview, CudaNdarray_DEV_DATA(x
view),
if(CudaNdarray_set_device_data(
zview, CudaNdarray_DEV_DATA(z
view),
%(x)
s)){
PyErr_Format(PyExc_RuntimeError,
"GpuSubtensor is not able to set"
" the base of the view array");
Py_XDECREF(
x
view);
Py_XDECREF(
z
view);
%(fail)
s;
}"""
%
locals
()
def
add_to_
x
view
(
self
,
x
,
fail
):
def
add_to_
z
view
(
self
,
x
,
fail
):
return
"""
PyObject * add_result = CudaNdarray_inplace_add((PyObject *)
x
view,
PyObject * add_result = CudaNdarray_inplace_add((PyObject *)
z
view,
(PyObject *) py_
%(x)
s);
if (! add_result )
{
Py_DECREF(
x
view);
Py_DECREF(
z
view);
%(fail)
s;
}
else
...
...
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
5fe90b3d
...
...
@@ -101,33 +101,42 @@ int device_free(void *ptr)
// it returns something else I still don't see why we should ignore
// it. All we want to do here is reset the flag.
cudaGetLastError
();
#if COMPUTE_GPU_MEM_USED
fprintf
(
stderr
,
"Error freeing device pointer %p (%s).%d byte already allocated
\n
"
,
ptr
,
cudaGetErrorString
(
err
),
_allocated_size
);
#else
fprintf
(
stderr
,
"Error freeing device pointer %p (%s).
\n
"
,
ptr
,
cudaGetErrorString
(
err
));
#endif
PyErr_Format
(
PyExc_MemoryError
,
"error freeing device pointer %p (%s)"
,
ptr
,
cudaGetErrorString
(
err
));
#if COMPUTE_GPU_MEM_USED
fprintf
(
stderr
,
"Error freeing device pointer %p (%s).%d byte already allocated
\n
"
,
ptr
,
cudaGetErrorString
(
err
),
_allocated_size
);
#else
fprintf
(
stderr
,
"Error freeing device pointer %p (%s).
\n
"
,
ptr
,
cudaGetErrorString
(
err
));
#endif
PyErr_Format
(
PyExc_MemoryError
,
"error freeing device pointer %p (%s)"
,
ptr
,
cudaGetErrorString
(
err
));
return
-
1
;
}
_outstanding_mallocs
[
0
]
-=
(
ptr
!=
NULL
);
#if COMPUTE_GPU_MEM_USED
int
i
=
0
;
size_t
total_freed
=
0
;
for
(;
i
<
TABLE_SIZE
;
i
++
)
if
(
_alloc_size_table
[
i
].
ptr
==
ptr
){
_allocated_size
-=
_alloc_size_table
[
i
].
size
;
total_freed
+=
_alloc_size_table
[
i
].
size
;
_alloc_size_table
[
i
].
ptr
=
0
;
_alloc_size_table
[
i
].
size
=
0
;
#if COMPUTE_GPU_MEM_USED
int
i
=
0
;
size_t
total_freed
=
0
;
for
(;
i
<
TABLE_SIZE
;
i
++
)
if
(
_alloc_size_table
[
i
].
ptr
==
ptr
){
_allocated_size
-=
_alloc_size_table
[
i
].
size
;
total_freed
+=
_alloc_size_table
[
i
].
size
;
_alloc_size_table
[
i
].
ptr
=
0
;
_alloc_size_table
[
i
].
size
=
0
;
break
;
}
//if(i==TABLE_SIZE)
// printf("Unallocated unknow size!\n");
//fprintf(stderr, "freed %li bytes of device memory (%s). %d already allocated, ptr=%p\n", (long)total_freed, cudaGetErrorString(err),_allocated_size,ptr);
#endif
break
;
}
//if(i==TABLE_SIZE)
// printf("Unallocated unknow size!\n");
//fprintf(stderr, "freed %li bytes of device memory (%s). %d already allocated, ptr=%p\n", (long)total_freed, cudaGetErrorString(err),_allocated_size,ptr);
#endif
return
0
;
}
static
PyObject
*
outstanding_mallocs
(
PyObject
*
self
,
PyObject
*
args
)
{
...
...
theano/tensor/basic.py
浏览文件 @
5fe90b3d
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论