Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e4533cec
提交
e4533cec
authored
3月 04, 2015
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Optimize CPU max pooling with padding to cudnn
上级
6f9b538b
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
12 行增加
和
10 行删除
+12
-10
dnn.py
theano/sandbox/cuda/dnn.py
+4
-2
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+8
-8
没有找到文件。
theano/sandbox/cuda/dnn.py
浏览文件 @
e4533cec
...
@@ -1483,9 +1483,10 @@ if True:
...
@@ -1483,9 +1483,10 @@ if True:
img
,
=
node
.
inputs
img
,
=
node
.
inputs
ds
=
node
.
op
.
ds
ds
=
node
.
op
.
ds
stride
=
node
.
op
.
st
stride
=
node
.
op
.
st
pad
=
node
.
op
.
padding
if
(
img
.
owner
and
isinstance
(
img
.
owner
.
op
,
HostFromGpu
)):
if
(
img
.
owner
and
isinstance
(
img
.
owner
.
op
,
HostFromGpu
)):
ret
=
dnn_pool
(
gpu_contiguous
(
img
.
owner
.
inputs
[
0
]),
ret
=
dnn_pool
(
gpu_contiguous
(
img
.
owner
.
inputs
[
0
]),
ds
,
stride
=
stride
)
ds
,
stride
=
stride
,
pad
=
pad
)
return
[
host_from_gpu
(
ret
)]
return
[
host_from_gpu
(
ret
)]
@register_opt
(
'cudnn'
)
@register_opt
(
'cudnn'
)
...
@@ -1514,12 +1515,13 @@ if True:
...
@@ -1514,12 +1515,13 @@ if True:
inp
,
out
,
inp_grad
=
node
.
inputs
inp
,
out
,
inp_grad
=
node
.
inputs
ds
=
node
.
op
.
ds
ds
=
node
.
op
.
ds
st
=
node
.
op
.
st
st
=
node
.
op
.
st
pad
=
node
.
op
.
padding
if
((
inp
.
owner
and
isinstance
(
inp
.
owner
.
op
,
HostFromGpu
))
or
if
((
inp
.
owner
and
isinstance
(
inp
.
owner
.
op
,
HostFromGpu
))
or
(
out
.
owner
and
isinstance
(
out
.
owner
.
op
,
HostFromGpu
))
or
(
out
.
owner
and
isinstance
(
out
.
owner
.
op
,
HostFromGpu
))
or
(
inp_grad
.
owner
and
isinstance
(
inp_grad
.
owner
.
op
,
HostFromGpu
))
(
inp_grad
.
owner
and
isinstance
(
inp_grad
.
owner
.
op
,
HostFromGpu
))
):
):
desc
=
GpuDnnPoolDesc
(
ws
=
ds
,
stride
=
st
,
mode
=
"max"
)()
desc
=
GpuDnnPoolDesc
(
ws
=
ds
,
stride
=
st
,
mode
=
"max"
,
pad
=
pad
)()
if
not
node
.
op
.
ignore_border
:
if
not
node
.
op
.
ignore_border
:
return
return
ret
=
GpuDnnPoolGrad
()(
gpu_contiguous
(
inp
),
ret
=
GpuDnnPoolGrad
()(
gpu_contiguous
(
inp
),
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
e4533cec
...
@@ -79,12 +79,12 @@ def test_pooling():
...
@@ -79,12 +79,12 @@ def test_pooling():
for
stride
in
(
2
,
3
):
for
stride
in
(
2
,
3
):
if
stride
>
ws
:
if
stride
>
ws
:
continue
continue
if
func
is
T
.
max
and
pad
==
(
0
,
0
)
:
if
func
is
T
.
max
:
# We will check that the opt introduced it.
# We will check that the opt introduced it.
out1
=
max_pool_2d
(
x
,
(
ws
,
ws
),
out1
=
max_pool_2d
(
x
,
(
ws
,
ws
),
st
=
(
stride
,
stride
),
st
=
(
stride
,
stride
),
ignore_border
=
True
,
)
ignore_border
=
True
,
# pad
=pad)
padding
=
pad
)
else
:
else
:
out1
=
cuda
.
dnn
.
dnn_pool
(
out1
=
cuda
.
dnn
.
dnn_pool
(
x
,
ws
=
(
ws
,
ws
),
x
,
ws
=
(
ws
,
ws
),
...
@@ -120,13 +120,13 @@ def test_pooling():
...
@@ -120,13 +120,13 @@ def test_pooling():
data
=
numpy
.
random
.
normal
(
0
,
1
,
shp
)
.
astype
(
"float32"
)
*
10
data
=
numpy
.
random
.
normal
(
0
,
1
,
shp
)
.
astype
(
"float32"
)
*
10
ws
=
2
ws
=
2
stride
s
=
2
stride
=
2
print
func
,
pad
,
ws
,
stride
,
shp
print
func
,
pad
,
ws
,
stride
,
shp
# This test the CPU grad + opt + GPU implemtentation
# This test the CPU grad + opt + GPU implemtentation
def
fn
(
x
):
def
fn
(
x
):
return
max_pool_2d
(
x
,
(
ws
,
ws
),
ignore_border
=
True
,
)
return
max_pool_2d
(
x
,
(
ws
,
ws
),
ignore_border
=
True
,
# pad
=pad)
padding
=
pad
)
theano
.
tests
.
unittest_tools
.
verify_grad
(
fn
,
[
data
],
theano
.
tests
.
unittest_tools
.
verify_grad
(
fn
,
[
data
],
cast_to_output_type
=
False
,
cast_to_output_type
=
False
,
mode
=
mode_with_gpu
)
mode
=
mode_with_gpu
)
...
@@ -155,10 +155,10 @@ def test_pooling():
...
@@ -155,10 +155,10 @@ def test_pooling():
for
node
in
fg
.
maker
.
fgraph
.
toposort
()])
for
node
in
fg
.
maker
.
fgraph
.
toposort
()])
g_out
=
fg
(
data
)
g_out
=
fg
(
data
)
if
func
is
T
.
max
and
pad
==
(
0
,
0
)
:
if
func
is
T
.
max
:
# Compare again the CPU result
# Compare again the CPU result
out
=
max_pool_2d
(
x
,
(
ws
,
ws
),
out
=
max_pool_2d
(
x
,
(
ws
,
ws
),
# pad
=pad,
padding
=
pad
,
ignore_border
=
True
)
ignore_border
=
True
)
fc
=
theano
.
function
([
x
],
theano
.
grad
(
out
.
sum
(),
x
),
fc
=
theano
.
function
([
x
],
theano
.
grad
(
out
.
sum
(),
x
),
mode
=
mode_without_gpu
)
mode
=
mode_without_gpu
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论