Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a92b7304
提交
a92b7304
authored
4月 22, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2808 from nouiz/fix_crash_gpu
[REGRESSION, CRASH]Fix crash gpu
上级
b24d1a8d
736574dc
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
40 行增加
和
17 行删除
+40
-17
nnet.py
theano/sandbox/cuda/nnet.py
+19
-8
test_nnet.py
theano/sandbox/cuda/tests/test_nnet.py
+2
-1
nnet.py
theano/sandbox/gpuarray/nnet.py
+19
-8
没有找到文件。
theano/sandbox/cuda/nnet.py
浏览文件 @
a92b7304
...
@@ -247,31 +247,42 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuOp):
...
@@ -247,31 +247,42 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuOp):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
# return ()
# return ()
return
(
6
,)
return
(
7
,)
def
c_code
(
self
,
node
,
nodename
,
inp
,
out
,
sub
):
def
c_code
(
self
,
node
,
nodename
,
inp
,
out
,
sub
):
dnll
,
sm
,
y_idx
=
inp
dnll
,
sm
,
y_idx
=
inp
dx
,
=
out
dx
,
=
out
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
return
"""
return
"""
if ((CudaNdarray_NDIM(
%(dnll)
s) != 1)
// Get `dnll.shape[0]` or set it to zero if `dnll` is a scalar.
const npy_intp
%(dnll)
s_dims0 = (CudaNdarray_NDIM(
%(dnll)
s) > 0 ?
CudaNdarray_HOST_DIMS(
%(dnll)
s)[0] :
(npy_intp) 0);
// Get `dnll.strides[0]` and set it to zero if `dnll` is a scalar
// or a vector with just one element.
const npy_intp
%(dnll)
s_strides0 = (
%(dnll)
s_dims0 > 1 ?
CudaNdarray_HOST_STRIDES(
%(dnll)
s)[0] :
(npy_intp) 0);
if ((CudaNdarray_NDIM(
%(dnll)
s) > 1)
|| (CudaNdarray_NDIM(
%(sm)
s) != 2)
|| (CudaNdarray_NDIM(
%(sm)
s) != 2)
|| (CudaNdarray_NDIM(
%(y_idx)
s) != 1))
|| (CudaNdarray_NDIM(
%(y_idx)
s) != 1))
{
{
PyErr_SetString(PyExc_ValueError, "rank error");
PyErr_SetString(PyExc_ValueError, "rank error");
%(fail)
s;
%(fail)
s;
}
}
if (
CudaNdarray_HOST_DIMS(
%(dnll)
s)[0]
!=
if (
%(dnll)
s_dims0
!=
CudaNdarray_HOST_DIMS(
%(sm)
s)[0])
CudaNdarray_HOST_DIMS(
%(sm)
s)[0]
&&
%(dnll)
s_dims0 > 1
)
{
{
PyErr_Format(PyExc_ValueError,
PyErr_Format(PyExc_ValueError,
"dnll.shape[0] ==
%%
i, but sm.shape[0] ==
%%
i",
"dnll.shape[0] ==
%%
i, but sm.shape[0] ==
%%
i",
CudaNdarray_HOST_DIMS(
%(dnll)
s)[0]
,
%(dnll)
s_dims0
,
CudaNdarray_HOST_DIMS(
%(sm)
s)[0]);
CudaNdarray_HOST_DIMS(
%(sm)
s)[0]);
%(fail)
s;
%(fail)
s;
}
}
if (
CudaNdarray_HOST_DIMS(
%(dnll)
s)[0]
!=
if (
%(dnll)
s_dims0
!=
CudaNdarray_HOST_DIMS(
%(y_idx)
s)[0])
CudaNdarray_HOST_DIMS(
%(y_idx)
s)[0]
&&
%(dnll)
s_dims0 > 1
)
{
{
PyErr_SetString(PyExc_ValueError,
PyErr_SetString(PyExc_ValueError,
"dnll.shape[0] != y_idx.shape[0]");
"dnll.shape[0] != y_idx.shape[0]");
...
@@ -305,7 +316,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuOp):
...
@@ -305,7 +316,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(GpuOp):
CudaNdarray_HOST_DIMS(
%(dx)
s)[1],
CudaNdarray_HOST_DIMS(
%(dx)
s)[1],
CudaNdarray_DEV_DATA(
%(dnll)
s),
CudaNdarray_DEV_DATA(
%(dnll)
s),
CudaNdarray_HOST_STRIDES(
%(dnll)
s)[0]
,
%(dnll)
s_strides0
,
CudaNdarray_DEV_DATA(
%(sm)
s),
CudaNdarray_DEV_DATA(
%(sm)
s),
CudaNdarray_HOST_STRIDES(
%(sm)
s)[0],
CudaNdarray_HOST_STRIDES(
%(sm)
s)[0],
...
...
theano/sandbox/cuda/tests/test_nnet.py
浏览文件 @
a92b7304
...
@@ -353,7 +353,8 @@ class test_SoftMax(unittest.TestCase):
...
@@ -353,7 +353,8 @@ class test_SoftMax(unittest.TestCase):
numpy
.
product
(
dims
),
numpy
.
product
(
dims
),
dtype
=
'float32'
dtype
=
'float32'
)
.
reshape
(
dims
)
)
.
reshape
(
dims
)
T
.
verify_grad
(
f_gpu
,
[
gdata
],
rng
=
numpy
.
random
)
T
.
verify_grad
(
f_gpu
,
[
gdata
],
rng
=
numpy
.
random
,
mode
=
mode_with_gpu
)
def
check_types
(
graph
,
graph_gpu
):
def
check_types
(
graph
,
graph_gpu
):
self
.
_check_types
(
self
.
_check_types
(
...
...
theano/sandbox/gpuarray/nnet.py
浏览文件 @
a92b7304
...
@@ -295,7 +295,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
...
@@ -295,7 +295,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
def
c_code_cache_version
(
self
):
def
c_code_cache_version
(
self
):
# return ()
# return ()
return
(
6
,)
return
(
7
,)
def
c_headers
(
self
):
def
c_headers
(
self
):
return
[
'cuda.h'
,
'<gpuarray/extension.h>'
,
'<numpy_compat.h>'
]
return
[
'cuda.h'
,
'<gpuarray/extension.h>'
,
'<numpy_compat.h>'
]
...
@@ -317,24 +317,35 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
...
@@ -317,24 +317,35 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
dx
,
=
out
dx
,
=
out
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
return
"""
return
"""
if ((PyGpuArray_NDIM(
%(dnll)
s) != 1)
// Get `dnll.shape[0]` or set it to zero if `dnll` is a scalar.
const npy_intp
%(dnll)
s_dims0 = (PyGpuArray_NDIM(
%(dnll)
s) > 0 ?
PyGpuArray_DIMS(
%(dnll)
s)[0] :
(npy_intp) 0);
// Get `dnll.strides[0]` and set it to zero if `dnll` is a scalar
// or a vector with just one element.
const npy_intp
%(dnll)
s_strides0 = (
%(dnll)
s_dims0 > 1 ?
PyGpuArray_STRIDES(
%(dnll)
s)[0] :
(npy_intp) 0);
if ((PyGpuArray_NDIM(
%(dnll)
s) > 1)
|| (PyGpuArray_NDIM(
%(sm)
s) != 2)
|| (PyGpuArray_NDIM(
%(sm)
s) != 2)
|| (PyGpuArray_NDIM(
%(y_idx)
s) != 1))
|| (PyGpuArray_NDIM(
%(y_idx)
s) != 1))
{
{
PyErr_SetString(PyExc_ValueError, "rank error");
PyErr_SetString(PyExc_ValueError, "rank error");
%(fail)
s;
%(fail)
s;
}
}
if (
PyGpuArray_DIMS(
%(dnll)
s)[0]
!=
if (
%(dnll)
s_dims0
!=
PyGpuArray_DIMS(
%(sm)
s)[0])
PyGpuArray_DIMS(
%(sm)
s)[0]
&&
%(dnll)
s_dims0 > 1
)
{
{
PyErr_Format(PyExc_ValueError,
PyErr_Format(PyExc_ValueError,
"dnll.shape[0] ==
%%
i, but sm.shape[0] ==
%%
i",
"dnll.shape[0] ==
%%
i, but sm.shape[0] ==
%%
i",
PyGpuArray_DIMS(
%(dnll)
s)[0]
,
%(dnll)
s_dims0
,
PyGpuArray_DIMS(
%(sm)
s)[0]);
PyGpuArray_DIMS(
%(sm)
s)[0]);
%(fail)
s;
%(fail)
s;
}
}
if (
PyGpuArray_DIMS(
%(dnll)
s)[0]
!=
if (
%(dnll)
s_dims0
!=
PyGpuArray_DIMS(
%(y_idx)
s)[0])
PyGpuArray_DIMS(
%(y_idx)
s)[0]
&&
%(dnll)
s_dims0 > 1
)
{
{
PyErr_SetString(PyExc_ValueError,
PyErr_SetString(PyExc_ValueError,
"dnll.shape[0] != y_idx.shape[0]");
"dnll.shape[0] != y_idx.shape[0]");
...
@@ -366,7 +377,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
...
@@ -366,7 +377,7 @@ class GpuCrossentropySoftmax1HotWithBiasDx(Op):
(npy_
%(dtype_dnll)
s*)(((char *)cuda_get_ptr(
%(dnll)
s->ga.data)) +
(npy_
%(dtype_dnll)
s*)(((char *)cuda_get_ptr(
%(dnll)
s->ga.data)) +
%(dnll)
s->ga.offset),
%(dnll)
s->ga.offset),
PyGpuArray_STRIDES(
%(dnll)
s)[0]
/
%(itemsize_dnll)
s,
%(dnll)
s_strides0
/
%(itemsize_dnll)
s,
(npy_
%(dtype_sm)
s*)(((char *)cuda_get_ptr(
%(sm)
s->ga.data)) +
(npy_
%(dtype_sm)
s*)(((char *)cuda_get_ptr(
%(sm)
s->ga.data)) +
%(sm)
s->ga.offset),
%(sm)
s->ga.offset),
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论