Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6e3837ba
提交
6e3837ba
authored
3月 12, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2608 from nouiz/dnn
[WIP] Disable some optimization that could cause problem with cudnn v2 rc3.
上级
9d9dc0ce
c1c79619
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
18 行增加
和
8 行删除
+18
-8
basic_ops.py
theano/sandbox/cuda/basic_ops.py
+3
-0
dnn.py
theano/sandbox/cuda/dnn.py
+13
-6
opt.py
theano/sandbox/cuda/opt.py
+1
-1
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+1
-1
没有找到文件。
theano/sandbox/cuda/basic_ops.py
浏览文件 @
6e3837ba
...
...
@@ -3434,6 +3434,9 @@ class CopyOnNegativeStrides(GpuOp):
i
=
i
.
copy
()
out
[
0
][
0
]
=
i
def
infer_shape
(
self
,
node
,
xshp
):
return
xshp
def
c_code
(
self
,
node
,
name
,
inp
,
out
,
sub
):
input
,
=
inp
z
,
=
out
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
6e3837ba
...
...
@@ -649,12 +649,19 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
capability of 3.0 or higer. This means that older GPU will not
work with this Op.
"""
def
contig_version
(
var
):
if
version
()
==
-
1
:
var
=
gpu_contiguous
(
var
)
else
:
var
=
cp_on_negative_strides
(
var
)
return
var
fgraph
=
getattr
(
img
,
'fgraph'
,
None
)
or
getattr
(
kerns
,
'fgraph'
,
None
)
if
(
border_mode
==
'valid'
and
subsample
==
(
1
,
1
)
and
direction_hint
==
'bprop weights'
):
# Special case: We are asked to use GpuDnnConvGradW. We need to set
# up a suitable 'fake' convolution to compute the gradient for.
img
=
c
p_on_negative_strides
(
img
.
dimshuffle
(
1
,
0
,
2
,
3
))
img
=
c
ontig_version
(
img
.
dimshuffle
(
1
,
0
,
2
,
3
))
if
conv_mode
==
'conv'
:
# We need to flip manually. These 'kerns' are not the kernels
# that would be flipped by conv_mode='conv' in GpuDnnConvGradW.
...
...
@@ -674,7 +681,7 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
# Special case: We can be faster by using GpuDnnConvGradI to compute
# the full convolution as the backward pass of a valid convolution.
# We just need to set up a suitable 'fake' valid convolution.
img
=
cp_on_negative_strides
(
img
)
img
=
gpu_contiguous
(
img
)
# cudnn v1 and v2 rc3 need contiguous data
kerns
=
gpu_contiguous
(
kerns
.
dimshuffle
(
1
,
0
,
2
,
3
))
conv_mode
=
'cross'
if
conv_mode
==
'conv'
else
'conv'
shape2
=
shape_i
(
img
,
2
,
fgraph
)
+
shape_i
(
kerns
,
2
,
fgraph
)
-
1
...
...
@@ -686,9 +693,9 @@ def dnn_conv(img, kerns, border_mode='valid', subsample=(1, 1),
return
GpuDnnConvGradI
()(
kerns
,
img
,
out
,
desc
)
# Standard case: We use GpuDnnConv with suitable padding.
# c
p_on_negative_strides
will return a gpu_contiguous copy
# c
ontig_version
will return a gpu_contiguous copy
# if the img contains negative strides
img
=
c
p_on_negative_strides
(
img
)
img
=
c
ontig_version
(
img
)
kerns
=
gpu_contiguous
(
kerns
)
desc
=
GpuDnnConvDesc
(
border_mode
=
border_mode
,
subsample
=
subsample
,
conv_mode
=
conv_mode
)(
img
.
shape
,
kerns
.
shape
)
...
...
@@ -746,7 +753,7 @@ class GpuDnnPoolDesc(GpuOp):
self
.
stride
=
stride
assert
len
(
stride
)
==
2
self
.
pad
=
pad
if
(
pad
[
0
]
!=
0
or
pad
[
1
]
!=
0
)
and
version
()
<
20
:
if
(
pad
[
0
]
!=
0
or
pad
[
1
]
!=
0
)
and
version
()
==
-
1
:
raise
RuntimeError
(
"CuDNN pooling with padding requires CuDNN v2"
)
def
__setstate__
(
self
,
d
):
...
...
@@ -755,7 +762,7 @@ class GpuDnnPoolDesc(GpuOp):
self
.
pad
=
(
0
,
0
)
def
make_node
(
self
):
if
self
.
pad
!=
(
0
,
0
)
and
version
()
<
20
:
if
self
.
pad
!=
(
0
,
0
)
and
version
()
==
-
1
:
raise
RuntimeError
(
"CuDNN pooling with padding requires CuDNN v2"
)
return
Apply
(
self
,
[],
...
...
theano/sandbox/cuda/opt.py
浏览文件 @
6e3837ba
...
...
@@ -1763,7 +1763,7 @@ def get_device_type_sizes():
del
t
except
Exception
,
e
:
_logger
.
warning
((
"Optimization Warning: "
"Got the following error, but
we
can ignore it. "
"Got the following error, but
you
can ignore it. "
"This could cause less GpuElemwise fused together.
\n
"
"
%
s"
)
%
e
)
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
6e3837ba
...
...
@@ -70,7 +70,7 @@ def test_pooling():
x
=
T
.
ftensor4
()
for
func
,
pad
in
product
((
T
.
max
,
T
.
mean
),
((
0
,
0
),
(
1
,
0
),
(
1
,
0
),
(
2
,
3
),
(
3
,
2
))):
if
pad
!=
(
0
,
0
)
and
cuda
.
dnn
.
version
()
<
20
:
if
pad
!=
(
0
,
0
)
and
cuda
.
dnn
.
version
()
==
-
1
:
continue
if
pad
!=
(
0
,
0
)
and
func
is
T
.
mean
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论