Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
42b861a0
提交
42b861a0
authored
9月 11, 2015
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #3379 from lamblin/fix_pooldesc_merge
Enable merging of GpuDnnPoolDesc
上级
94c6aff4
4bea8d5c
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
31 行增加
和
4 行删除
+31
-4
opt.py
theano/gof/opt.py
+18
-4
test_opt.py
theano/gof/tests/test_opt.py
+0
-0
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+13
-0
没有找到文件。
theano/gof/opt.py
浏览文件 @
42b861a0
...
@@ -484,9 +484,11 @@ class MergeFeature(object):
...
@@ -484,9 +484,11 @@ class MergeFeature(object):
# signature -> variable (for constants)
# signature -> variable (for constants)
self
.
const_sig_inv
=
_metadict
()
self
.
const_sig_inv
=
_metadict
()
# For all
variabl
es
# For all
Apply nod
es
# Set of distinct (not mergeable) nodes
# Set of distinct (not mergeable) nodes
self
.
nodes_seen
=
set
()
self
.
nodes_seen
=
set
()
# Ordered set of distinct (not mergeable) nodes without any input
self
.
noinput_nodes
=
OrderedSet
()
# Each element of scheduled is a list of list of (out, new_out) pairs.
# Each element of scheduled is a list of list of (out, new_out) pairs.
# Each list of pairs represent the substitution needed to replace all
# Each list of pairs represent the substitution needed to replace all
...
@@ -514,6 +516,10 @@ class MergeFeature(object):
...
@@ -514,6 +516,10 @@ class MergeFeature(object):
self
.
nodes_seen
.
discard
(
node
)
self
.
nodes_seen
.
discard
(
node
)
self
.
process_node
(
fgraph
,
node
)
self
.
process_node
(
fgraph
,
node
)
# Since we are in on_change_input, node should have inputs.
if
not
isinstance
(
node
,
string_types
):
assert
node
.
inputs
if
isinstance
(
new_r
,
graph
.
Constant
):
if
isinstance
(
new_r
,
graph
.
Constant
):
self
.
process_constant
(
fgraph
,
new_r
)
self
.
process_constant
(
fgraph
,
new_r
)
...
@@ -526,6 +532,8 @@ class MergeFeature(object):
...
@@ -526,6 +532,8 @@ class MergeFeature(object):
def
on_prune
(
self
,
fgraph
,
node
,
reason
):
def
on_prune
(
self
,
fgraph
,
node
,
reason
):
self
.
nodes_seen
.
discard
(
node
)
self
.
nodes_seen
.
discard
(
node
)
if
not
node
.
inputs
:
self
.
noinput_nodes
.
discard
(
node
)
for
c
in
node
.
inputs
:
for
c
in
node
.
inputs
:
if
isinstance
(
c
,
graph
.
Constant
)
and
(
len
(
c
.
clients
)
<=
1
):
if
isinstance
(
c
,
graph
.
Constant
)
and
(
len
(
c
.
clients
)
<=
1
):
# This was the last node using this constant
# This was the last node using this constant
...
@@ -592,7 +600,10 @@ class MergeFeature(object):
...
@@ -592,7 +600,10 @@ class MergeFeature(object):
merge_candidates
.
extend
(
assert_clients
)
merge_candidates
.
extend
(
assert_clients
)
else
:
else
:
merge_candidates
=
[]
# If two nodes have no input, but perform the same operation,
# they are not always constant-folded, so we want to merge them.
# In that case, the candidates are all the nodes without inputs.
merge_candidates
=
self
.
noinput_nodes
replacement_candidates
=
[]
replacement_candidates
=
[]
for
candidate
in
merge_candidates
:
for
candidate
in
merge_candidates
:
...
@@ -672,6 +683,8 @@ class MergeFeature(object):
...
@@ -672,6 +683,8 @@ class MergeFeature(object):
self
.
scheduled
.
append
(
replacement_candidates
)
self
.
scheduled
.
append
(
replacement_candidates
)
else
:
else
:
self
.
nodes_seen
.
add
(
node
)
self
.
nodes_seen
.
add
(
node
)
if
not
node
.
inputs
:
self
.
noinput_nodes
.
add
(
node
)
def
get_merged_assert_input
(
self
,
node
,
candidate
):
def
get_merged_assert_input
(
self
,
node
,
candidate
):
new_inputs
=
[]
new_inputs
=
[]
...
@@ -2217,7 +2230,7 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -2217,7 +2230,7 @@ class EquilibriumOptimizer(NavigatorOptimizer):
process_count
=
{}
process_count
=
{}
for
o
in
(
opt
.
global_optimizers
+
for
o
in
(
opt
.
global_optimizers
+
list
(
opt
.
get_local_optimizers
())
+
list
(
opt
.
get_local_optimizers
())
+
opt
.
final_optimizers
):
list
(
opt
.
final_optimizers
)
):
process_count
.
setdefault
(
o
,
0
)
process_count
.
setdefault
(
o
,
0
)
for
count
in
loop_process_count
:
for
count
in
loop_process_count
:
for
o
,
v
in
iteritems
(
count
):
for
o
,
v
in
iteritems
(
count
):
...
@@ -2246,7 +2259,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -2246,7 +2259,8 @@ class EquilibriumOptimizer(NavigatorOptimizer):
# Skip opt that have 0 times, they probably wasn't even tried.
# Skip opt that have 0 times, they probably wasn't even tried.
print
(
blanc
+
" "
,
'
%.3
fs -
%
s'
%
(
t
,
o
),
file
=
stream
)
print
(
blanc
+
" "
,
'
%.3
fs -
%
s'
%
(
t
,
o
),
file
=
stream
)
print
(
file
=
stream
)
print
(
file
=
stream
)
gf_opts
=
[
o
for
o
in
opt
.
global_optimizers
+
opt
.
final_optimizers
gf_opts
=
[
o
for
o
in
(
opt
.
global_optimizers
+
list
(
opt
.
final_optimizers
))
if
o
.
print_profile
.
func_code
is
not
if
o
.
print_profile
.
func_code
is
not
Optimizer
.
print_profile
.
func_code
]
Optimizer
.
print_profile
.
func_code
]
if
not
gf_opts
:
if
not
gf_opts
:
...
...
theano/gof/tests/test_opt.py
浏览文件 @
42b861a0
差异被折叠。
点击展开。
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
42b861a0
...
@@ -68,6 +68,19 @@ def test_dnn_conv_desc_merge():
...
@@ -68,6 +68,19 @@ def test_dnn_conv_desc_merge():
assert
d1
==
d2
assert
d1
==
d2
def
test_dnn_pool_desc_merge
():
if
not
cuda
.
dnn
.
dnn_available
():
raise
SkipTest
(
cuda
.
dnn
.
dnn_available
.
msg
)
x
=
theano
.
tensor
.
ftensor4
(
'x'
)
y
=
dnn
.
dnn_pool
(
x
,
(
2
,
2
))
z
=
dnn
.
dnn_pool
(
x
,
(
2
,
2
))
f
=
theano
.
function
([
x
],
[
y
,
z
])
descs
=
[
n
for
n
in
f
.
maker
.
fgraph
.
apply_nodes
if
isinstance
(
n
.
op
,
dnn
.
GpuDnnPoolDesc
)]
assert
len
(
descs
)
==
1
,
f
.
maker
.
fgraph
def
test_dnn_conv_merge
():
def
test_dnn_conv_merge
():
"""This test that we merge correctly multiple dnn_conv.
"""This test that we merge correctly multiple dnn_conv.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论