Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b09557a6
提交
b09557a6
authored
7月 06, 2015
作者:
--global
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove 'nd' param from GpuDnnPoolDesc
上级
912d125e
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
16 行删除
+18
-16
dnn.py
theano/sandbox/cuda/dnn.py
+16
-14
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+2
-2
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
b09557a6
...
...
@@ -1264,7 +1264,7 @@ class GpuDnnPoolDesc(GpuOp):
padX is the size of the left and right borders,
padY is the size of the top and bottom borders.
"""
__props__
=
(
'ws'
,
'stride'
,
'mode'
,
'pad'
,
'nd'
)
__props__
=
(
'ws'
,
'stride'
,
'mode'
,
'pad'
)
def
c_headers
(
self
):
return
[
'cudnn.h'
,
'cudnn_helper.h'
]
...
...
@@ -1281,23 +1281,25 @@ class GpuDnnPoolDesc(GpuOp):
def
do_constant_folding
(
self
,
node
):
return
False
def
__init__
(
self
,
ws
=
(
1
,
1
),
stride
=
(
1
,
1
),
mode
=
'max'
,
pad
=
(
0
,
0
)
,
nd
=
2
):
def
__init__
(
self
,
ws
=
(
1
,
1
),
stride
=
(
1
,
1
),
mode
=
'max'
,
pad
=
(
0
,
0
)):
if
mode
==
'average'
:
mode
=
'average_inc_pad'
assert
mode
in
(
'max'
,
'average_inc_pad'
,
'average_exc_pad'
)
self
.
mode
=
mode
assert
len
(
ws
)
==
nd
assert
len
(
ws
)
==
len
(
stride
)
and
len
(
stride
)
==
len
(
pad
)
assert
len
(
ws
)
in
(
2
,
3
)
self
.
ws
=
ws
assert
len
(
stride
)
==
nd
self
.
stride
=
stride
assert
len
(
stride
)
==
nd
self
.
pad
=
pad
if
(
pad
[
0
]
!=
0
or
pad
[
1
]
!=
0
)
and
version
()
==
-
1
:
raise
RuntimeError
(
"CuDNN pooling with padding requires CuDNN v2"
)
assert
nd
in
(
2
,
3
)
if
nd
==
3
and
version
()
<
(
3000
,
3000
):
if
self
.
get_ndim
()
==
3
and
version
()
<
(
3000
,
3000
):
raise
RuntimeError
(
"CuDNN 3d pooling requires CuDNN v3"
)
self
.
nd
=
nd
def
get_ndim
(
self
):
return
len
(
self
.
ws
)
def
__setstate__
(
self
,
d
):
self
.
__dict__
.
update
(
d
)
...
...
@@ -1350,7 +1352,7 @@ class GpuDnnPoolDesc(GpuOp):
}
}
"""
%
dict
(
name
=
name
,
desc
=
desc
,
mode_flag
=
mode_flag
,
fail
=
sub
[
'fail'
],
nd
=
self
.
nd
,
win
=
', '
.
join
(
str
(
w
)
for
w
in
self
.
ws
),
nd
=
self
.
get_ndim
()
,
win
=
', '
.
join
(
str
(
w
)
for
w
in
self
.
ws
),
pad
=
', '
.
join
(
str
(
p
)
for
p
in
self
.
pad
),
str
=
', '
.
join
(
str
(
s
)
for
s
in
self
.
stride
))
...
...
@@ -1374,7 +1376,7 @@ class GpuDnnPool(DnnBase):
raise
TypeError
(
'desc must be cudnnPoolingDescriptor_t'
)
dop
=
desc
.
owner
.
op
e_ndim
=
dop
.
nd
+
2
# 4 or 5
e_ndim
=
dop
.
get_ndim
()
+
2
# 4 or 5
if
img
.
type
.
ndim
!=
e_ndim
:
raise
TypeError
(
'img must be
%
dD tensor'
%
e_ndim
)
...
...
@@ -1383,7 +1385,7 @@ class GpuDnnPool(DnnBase):
def
infer_shape
(
self
,
node
,
shape
):
desc
=
node
.
inputs
[
1
]
.
owner
.
op
nd
=
desc
.
nd
nd
=
desc
.
get_ndim
()
w
=
desc
.
ws
s
=
desc
.
stride
p
=
desc
.
pad
...
...
@@ -1531,7 +1533,7 @@ class GpuDnnPoolGrad(DnnBase):
or
desc
.
type
.
ctype
!=
'cudnnPoolingDescriptor_t'
:
raise
TypeError
(
'desc must be cudnnPoolingDescriptor_t'
)
nd
=
desc
.
owner
.
op
.
nd
+
2
# 4 or 5
nd
=
desc
.
owner
.
op
.
get_ndim
()
+
2
# 4 or 5
inp
=
as_cuda_ndarray_variable
(
inp
)
if
inp
.
type
.
ndim
!=
nd
:
...
...
@@ -1677,7 +1679,7 @@ if (err%(name)s != CUDNN_STATUS_SUCCESS) {
return
[
shape
[
0
]]
def
dnn_pool
(
img
,
ws
,
stride
=
(
1
,
1
),
mode
=
'max'
,
pad
=
(
0
,
0
)
,
nd
=
2
):
def
dnn_pool
(
img
,
ws
,
stride
=
(
1
,
1
),
mode
=
'max'
,
pad
=
(
0
,
0
)):
"""
GPU pooling using cuDNN from NVIDIA.
...
...
@@ -1702,7 +1704,7 @@ def dnn_pool(img, ws, stride=(1, 1), mode='max', pad=(0, 0), nd=2):
:note: This Op implements the ignore_border=True of max_pool_2d.
"""
img
=
gpu_contiguous
(
img
)
desc
=
GpuDnnPoolDesc
(
ws
=
ws
,
stride
=
stride
,
mode
=
mode
,
pad
=
pad
,
nd
=
nd
)()
desc
=
GpuDnnPoolDesc
(
ws
=
ws
,
stride
=
stride
,
mode
=
mode
,
pad
=
pad
)()
return
GpuDnnPool
()(
img
,
desc
)
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
b09557a6
...
...
@@ -350,7 +350,7 @@ def test_pooling3d():
continue
out1
=
cuda
.
dnn
.
dnn_pool
(
x
,
(
ws
,
ws
,
ws
),
stride
=
(
stride
,
stride
,
stride
),
pad
=
pad
,
mode
=
mode
,
nd
=
3
)
pad
=
pad
,
mode
=
mode
)
out2
=
pool3d2d
(
x
,
ds
=
(
ws
,
ws
,
ws
),
strides
=
(
stride
,
stride
,
stride
),
pad
=
pad
,
pool_func
=
func
)
...
...
@@ -390,7 +390,7 @@ def test_pooling3d():
x
,
ws
=
(
ws
,
ws
,
ws
),
stride
=
(
stride
,
stride
,
stride
),
pad
=
pad
,
mode
=
mode
,
nd
=
3
)
mode
=
mode
)
return
dnn_op
theano
.
tests
.
unittest_tools
.
verify_grad
(
fn
,
[
data
],
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论