Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f1bc93a6
提交
f1bc93a6
authored
2月 15, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Port the fix to the new back-end.
上级
23bca43d
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
41 行增加
和
15 行删除
+41
-15
dnn_pool.c
theano/gpuarray/dnn_pool.c
+14
-9
dnn_pool_grad.c
theano/gpuarray/dnn_pool_grad.c
+11
-6
test_dnn.py
theano/gpuarray/tests/test_dnn.py
+16
-0
没有找到文件。
theano/gpuarray/dnn_pool.c
浏览文件 @
f1bc93a6
...
...
@@ -52,9 +52,6 @@ int APPLY_SPECIFIC(dnn_pool)(PyGpuArrayObject *img,
return
1
;
}
if
(
c_set_tensorNd
(
img
,
APPLY_SPECIFIC
(
input
))
!=
0
)
return
1
;
cudnnPoolingMode_t
mode
;
int
w
[
3
];
int
p
[
3
];
...
...
@@ -71,12 +68,6 @@ int APPLY_SPECIFIC(dnn_pool)(PyGpuArrayObject *img,
s
[
i
]
=
*
((
npy_intp
*
)
PyArray_GETPTR1
(
stride
,
i
));
}
err
=
cudnnSetPoolingNdDescriptor
(
APPLY_SPECIFIC
(
pool
),
MODE_FLAG
,
CUDNN_PROPAGATE_NAN
,
ndims
,
w
,
p
,
s
);
if
(
err
!=
CUDNN_STATUS_SUCCESS
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"could not set op descriptor %s"
,
cudnnGetErrorString
(
err
));
}
dims
[
0
]
=
PyGpuArray_DIM
(
img
,
0
);
dims
[
1
]
=
PyGpuArray_DIM
(
img
,
1
);
dims
[
2
]
=
(
PyGpuArray_DIM
(
img
,
2
)
+
(
p
[
0
]
*
2
)
-
w
[
0
])
/
s
[
0
]
+
1
;
...
...
@@ -88,9 +79,23 @@ int APPLY_SPECIFIC(dnn_pool)(PyGpuArrayObject *img,
GA_C_ORDER
,
c
)
!=
0
)
return
1
;
// if input batch is empty, we return the empty output without calling cuDNN
// (which will fail on zero batch size).
if
(
PyGpuArray_DIM
(
*
out
,
0
)
==
0
)
return
0
;
if
(
c_set_tensorNd
(
img
,
APPLY_SPECIFIC
(
input
))
!=
0
)
return
1
;
if
(
c_set_tensorNd
(
*
out
,
APPLY_SPECIFIC
(
output
))
!=
0
)
return
1
;
err
=
cudnnSetPoolingNdDescriptor
(
APPLY_SPECIFIC
(
pool
),
MODE_FLAG
,
CUDNN_PROPAGATE_NAN
,
ndims
,
w
,
p
,
s
);
if
(
err
!=
CUDNN_STATUS_SUCCESS
)
{
PyErr_Format
(
PyExc_RuntimeError
,
"could not set op descriptor %s"
,
cudnnGetErrorString
(
err
));
}
{
const
float
alphaf
=
1
;
const
float
betaf
=
0
;
...
...
theano/gpuarray/dnn_pool_grad.c
浏览文件 @
f1bc93a6
...
...
@@ -83,6 +83,17 @@ int APPLY_SPECIFIC(dnn_pool_grad)(PyGpuArrayObject *inp,
return
1
;
}
if
(
theano_prep_output
(
inp_grad
,
PyGpuArray_NDIM
(
inp
),
PyGpuArray_DIMS
(
inp
),
inp
->
ga
.
typecode
,
GA_C_ORDER
,
c
)
!=
0
)
{
return
1
;
}
// if input batch is empty, we return the empty output without calling cuDNN
// (which will fail on zero batch size).
if
(
PyGpuArray_DIM
(
*
inp_grad
,
0
)
==
0
)
return
0
;
if
(
c_set_tensorNd
(
inp
,
APPLY_SPECIFIC
(
input
))
!=
0
)
return
1
;
if
(
c_set_tensorNd
(
out_grad
,
APPLY_SPECIFIC
(
output_grad
))
!=
0
)
...
...
@@ -90,12 +101,6 @@ int APPLY_SPECIFIC(dnn_pool_grad)(PyGpuArrayObject *inp,
if
(
c_set_tensorNd
(
out
,
APPLY_SPECIFIC
(
output
))
!=
0
)
return
1
;
if
(
theano_prep_output
(
inp_grad
,
PyGpuArray_NDIM
(
inp
),
PyGpuArray_DIMS
(
inp
),
inp
->
ga
.
typecode
,
GA_C_ORDER
,
c
)
!=
0
)
{
return
1
;
}
int
w
[
3
];
int
p
[
3
];
int
s
[
3
];
...
...
theano/gpuarray/tests/test_dnn.py
浏览文件 @
f1bc93a6
...
...
@@ -502,6 +502,22 @@ def test_pooling_opt_arbitrary_dimensions():
utt
.
assert_allclose
(
res_gpu
[
1
],
res_cpu
[
1
])
def
test_pooling_empty_batch
():
img_shp
=
(
0
,
5
,
6
,
8
)
img
=
T
.
ftensor4
(
'img'
)
o
=
dnn
.
dnn_pool
(
img
,
(
2
,
2
),
(
2
,
2
))
f
=
theano
.
function
([
img
],
o
,
mode
=
mode_with_gpu
)
d
=
f
(
np
.
random
.
rand
(
*
img_shp
)
.
astype
(
'float32'
))
assert
d
.
shape
==
(
0
,
5
,
3
,
4
)
g
=
T
.
grad
(
T
.
sum
(
o
),
wrt
=
img
)
f
=
theano
.
function
([
img
],
g
,
mode
=
mode_with_gpu
)
d
=
f
(
np
.
random
.
rand
(
*
img_shp
)
.
astype
(
'float32'
))
# Not sure what to assert, it should just pass, that's all.
assert
d
.
shape
==
(
0
,
5
,
6
,
8
)
def
test_dnn_tag
():
"""
Test that if cudnn isn't avail we crash and that if it is avail, we use it.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论