Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
affc6d9e
提交
affc6d9e
authored
5月 11, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Assert that the size of int is the same on cpu and gpu.
上级
158b1edc
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
15 行增加
和
6 行删除
+15
-6
cuda_ndarray.cu
theano/sandbox/cuda/cuda_ndarray.cu
+8
-4
opt.py
theano/sandbox/cuda/opt.py
+7
-2
没有找到文件。
theano/sandbox/cuda/cuda_ndarray.cu
浏览文件 @
affc6d9e
...
@@ -1886,12 +1886,13 @@ static PyTypeObject CudaNdarrayType =
...
@@ -1886,12 +1886,13 @@ static PyTypeObject CudaNdarrayType =
static __global__ void get_gpu_ptr_size(int* dst)
static __global__ void get_gpu_ptr_size(int* dst)
{
{
dst[0] = sizeof(float*);
dst[0] = sizeof(float*);
dst[1] = sizeof(int);
}
}
PyObject *
PyObject *
CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
{
{
int *gpu_data = (int*)device_malloc(sizeof(int));
int *gpu_data = (int*)device_malloc(sizeof(int)
*2
);
if(gpu_data == NULL){
if(gpu_data == NULL){
return PyErr_Format(PyExc_MemoryError,
return PyErr_Format(PyExc_MemoryError,
"CudaNdarray_ptr_int_size: Can't allocate memory on the gpu.");
"CudaNdarray_ptr_int_size: Can't allocate memory on the gpu.");
...
@@ -1903,14 +1904,17 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
...
@@ -1903,14 +1904,17 @@ CudaNdarray_ptr_int_size(PyObject* _unused, PyObject* args)
return PyErr_Format(PyExc_RuntimeError,
return PyErr_Format(PyExc_RuntimeError,
"CudaNdarray_ptr_int_size: error when calling the gpu code.");
"CudaNdarray_ptr_int_size: error when calling the gpu code.");
}
}
int gpu_ptr_size = -1;
cublasGetVector(1, sizeof(int), gpu_data, 1, &gpu_ptr_size, 1);
// Transfer the result to cpu
int gpu_sizes[] = {-1,-1};
cublasGetVector(2, sizeof(int), gpu_data, 1, gpu_sizes, 1);
device_free(gpu_data);
device_free(gpu_data);
if (CUBLAS_STATUS_SUCCESS != cublasGetError()){
if (CUBLAS_STATUS_SUCCESS != cublasGetError()){
PyErr_SetString(PyExc_RuntimeError, "error copying data to from memory");
PyErr_SetString(PyExc_RuntimeError, "error copying data to from memory");
return NULL;
return NULL;
}
}
return Py_BuildValue("iii
", gpu_ptr_size, sizeof(float*), sizeof(int)
);
return Py_BuildValue("iii
i", gpu_sizes[0], sizeof(float*), sizeof(int), gpu_sizes[1]
);
}
}
// Initialize the gpu.
// Initialize the gpu.
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
affc6d9e
...
@@ -852,6 +852,10 @@ def local_gpu_join(node):
...
@@ -852,6 +852,10 @@ def local_gpu_join(node):
# 70.0, 'fast_run', 'inplace')
# 70.0, 'fast_run', 'inplace')
def
get_device_type_sizes
():
def
get_device_type_sizes
():
"""
:return:(gpu ptr size, cpu ptr size, int sizes(gpu and cpu))
:return type: tuple
"""
if
hasattr
(
get_device_type_sizes
,
'rval'
):
if
hasattr
(
get_device_type_sizes
,
'rval'
):
return
get_device_type_sizes
.
rval
return
get_device_type_sizes
.
rval
gpu_ptr_size
=
8
gpu_ptr_size
=
8
...
@@ -859,9 +863,10 @@ def get_device_type_sizes():
...
@@ -859,9 +863,10 @@ def get_device_type_sizes():
int_size
=
8
int_size
=
8
try
:
try
:
#RETURN (gpu ptr size, cpu ptr size, int sizes)
t
=
cuda_ndarray
.
cuda_ndarray
.
ptr_int_size
()
t
=
cuda_ndarray
.
cuda_ndarray
.
ptr_int_size
()
gpu_ptr_size
,
cpu_ptr_size
,
int_size
=
t
gpu_ptr_size
,
cpu_ptr_size
,
int_size
,
gpu_int_size
=
t
assert
int_size
==
gpu_int_size
del
gpu_int_size
del
t
del
t
except
Exception
,
e
:
except
Exception
,
e
:
_logger
.
warning
((
"OPTIMIZATION WARNING: "
_logger
.
warning
((
"OPTIMIZATION WARNING: "
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论