Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
354d7b57
提交
354d7b57
authored
7月 27, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2629 from abergeron/fix_merge_opts
Don't apply alpha_merge and output_merge when the proc node has more than one client.
上级
9da4c134
208acb3a
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
55 行增加
和
4 行删除
+55
-4
opt_util.py
theano/sandbox/cuda/opt_util.py
+5
-4
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+49
-0
opt_util.py
theano/sandbox/gpuarray/opt_util.py
+1
-0
没有找到文件。
theano/sandbox/cuda/opt_util.py
浏览文件 @
354d7b57
...
@@ -32,14 +32,15 @@ def grab_cpu_scalar(v, nd):
...
@@ -32,14 +32,15 @@ def grab_cpu_scalar(v, nd):
return
v
.
dimshuffle
(())
return
v
.
dimshuffle
(())
def
find_node
(
v
,
cls
):
def
find_node
(
v
,
cls
,
ignore_clients
=
False
):
# This digs through possibly redundant transfers to for the node
# This digs through possibly redundant transfers to for the node
# that has the op class specified.
# that has the op class specified.
if
v
.
owner
is
not
None
:
if
v
.
owner
is
not
None
and
(
ignore_clients
or
len
(
v
.
clients
)
==
1
)
:
if
isinstance
(
v
.
owner
.
op
,
cls
):
if
isinstance
(
v
.
owner
.
op
,
cls
):
return
v
.
owner
return
v
.
owner
elif
(
isinstance
(
v
.
owner
.
op
,
GpuFromHost
)
and
elif
(
isinstance
(
v
.
owner
.
op
,
GpuFromHost
)
and
v
.
owner
.
inputs
[
0
]
.
owner
is
not
None
and
v
.
owner
.
inputs
[
0
]
.
owner
is
not
None
and
(
ignore_clients
or
len
(
v
.
owner
.
inputs
[
0
]
.
clients
)
==
1
)
and
isinstance
(
v
.
owner
.
inputs
[
0
]
.
owner
.
op
,
HostFromGpu
)):
isinstance
(
v
.
owner
.
inputs
[
0
]
.
owner
.
op
,
HostFromGpu
)):
return
find_node
(
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
0
],
cls
)
return
find_node
(
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
0
],
cls
)
else
:
else
:
...
@@ -111,8 +112,8 @@ def output_merge(cls, alpha_in, beta_in, out_in, nd):
...
@@ -111,8 +112,8 @@ def output_merge(cls, alpha_in, beta_in, out_in, nd):
# other cases are too complex for now
# other cases are too complex for now
return
None
return
None
if
W
.
broadcastable
!=
targ
.
inputs
[
out_in
]
.
broadcastable
:
if
W
.
broadcastable
!=
targ
.
inputs
[
out_in
]
.
broadcastable
:
#
Would need to explicitly tile the output to fill
#
May change later to do the broadcast, but it's
#
the full shape here. Disable for now
.
#
under discussion
.
return
None
return
None
inputs
=
list
(
targ
.
inputs
)
inputs
=
list
(
targ
.
inputs
)
inputs
[
out_in
]
=
W
inputs
[
out_in
]
=
W
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
354d7b57
...
@@ -659,6 +659,55 @@ def test_dnn_conv_alpha_output_merge():
...
@@ -659,6 +659,55 @@ def test_dnn_conv_alpha_output_merge():
utt
.
assert_allclose
(
v1
,
v2
)
utt
.
assert_allclose
(
v1
,
v2
)
def
test_dnn_conv_merge_mouts
():
# make sure it doesn't attempt to output/alpha merge a convolution
# that has multiple clients.
if
not
cuda
.
dnn
.
dnn_available
():
raise
SkipTest
(
cuda
.
dnn
.
dnn_available
.
msg
)
img
=
T
.
ftensor4
()
kern
=
T
.
ftensor4
()
out
=
T
.
ftensor4
()
conv
=
dnn
.
dnn_conv
(
img
,
kern
)
lr
=
numpy
.
asarray
(
0.05
,
dtype
=
'float32'
)
if
cuda
.
dnn
.
version
()
==
-
1
:
# Can't merge alpha with cudnn v1
fr
=
conv
+
out
else
:
fr
=
lr
*
(
conv
+
out
)
rr
=
conv
*
lr
f
=
theano
.
function
([
img
,
kern
,
out
],
[
fr
,
rr
],
mode
=
mode_with_gpu
)
convs
=
[
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnConv
)]
assert
len
(
convs
)
==
1
def
test_dnn_conv_merge_broad
():
# Make sure that we don't apply output_merge on broadcasted values.
if
not
cuda
.
dnn
.
dnn_available
():
raise
SkipTest
(
cuda
.
dnn
.
dnn_available
.
msg
)
img
=
T
.
ftensor4
()
kern
=
T
.
ftensor4
()
conv
=
dnn
.
dnn_conv
(
img
,
kern
)
lr
=
numpy
.
asarray
(
0.05
,
dtype
=
'float32'
)
# this does broadcasting
fr
=
conv
+
lr
f
=
theano
.
function
([
img
,
kern
],
[
fr
])
convs
=
[
n
for
n
in
f
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnConv
)]
assert
len
(
convs
)
==
1
conv
=
convs
[
0
]
# Assert output was not merged
assert
isinstance
(
conv
.
inputs
[
2
]
.
owner
.
op
,
GpuAllocEmpty
)
def
test_dnn_conv_grad
():
def
test_dnn_conv_grad
():
if
not
cuda
.
dnn
.
dnn_available
()
or
dnn
.
version
()
==
-
1
:
if
not
cuda
.
dnn
.
dnn_available
()
or
dnn
.
version
()
==
-
1
:
raise
SkipTest
(
'alpha != 1.0 not supported in cudnn v1'
)
raise
SkipTest
(
'alpha != 1.0 not supported in cudnn v1'
)
...
...
theano/sandbox/gpuarray/opt_util.py
浏览文件 @
354d7b57
...
@@ -42,6 +42,7 @@ def find_node(v, cls, ignore_clients=False):
...
@@ -42,6 +42,7 @@ def find_node(v, cls, ignore_clients=False):
return
v
.
owner
return
v
.
owner
elif
(
isinstance
(
v
.
owner
.
op
,
GpuFromHost
)
and
elif
(
isinstance
(
v
.
owner
.
op
,
GpuFromHost
)
and
v
.
owner
.
inputs
[
0
]
.
owner
is
not
None
and
v
.
owner
.
inputs
[
0
]
.
owner
is
not
None
and
(
ignore_clients
or
len
(
v
.
owner
.
inputs
[
0
]
.
clients
)
==
1
)
and
isinstance
(
v
.
owner
.
inputs
[
0
]
.
owner
.
op
,
HostFromGpu
)):
isinstance
(
v
.
owner
.
inputs
[
0
]
.
owner
.
op
,
HostFromGpu
)):
return
find_node
(
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
0
],
cls
)
return
find_node
(
v
.
owner
.
inputs
[
0
]
.
owner
.
inputs
[
0
],
cls
)
else
:
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论