Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
bbc25bc6
提交
bbc25bc6
authored
1月 28, 2013
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1180 from lamblin/fix_infinite_opt_loop
Fix infinite opt loop
上级
d13064f7
d5c045e4
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
36 行增加
和
10 行删除
+36
-10
debugmode.py
theano/compile/debugmode.py
+14
-2
function_module.py
theano/compile/function_module.py
+6
-1
opt.py
theano/gof/opt.py
+14
-5
test_blas.py
theano/tensor/tests/test_blas.py
+2
-2
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
bbc25bc6
...
@@ -677,8 +677,13 @@ def _optcheck_fgraph(input_specs, output_specs, accept_inplace=False):
...
@@ -677,8 +677,13 @@ def _optcheck_fgraph(input_specs, output_specs, accept_inplace=False):
inputs
,
outputs
=
gof
.
graph
.
clone
(
orig_inputs
,
orig_outputs
)
inputs
,
outputs
=
gof
.
graph
.
clone
(
orig_inputs
,
orig_outputs
)
equivalence_tracker
=
_VariableEquivalenceTracker
()
equivalence_tracker
=
_VariableEquivalenceTracker
()
fgraph
=
gof
.
fg
.
FunctionGraph
(
inputs
,
outputs
,
fgraph
=
gof
.
fg
.
FunctionGraph
(
inputs
,
outputs
,
#DestroyHandler is not needed because it is actually installed by an optimization
# DestroyHandler may not be needed yet, as there is usually no
# after canonicalization. This variables in a big speed gain.
# inplace operation in the graph at this stage. DestroyHandler
# will be installed by an optimization after canonicalization,
# before the inplace operations are applied.
# This results in a big speed gain.
# If inplace operations are accepted and present, however,
# DestroyHandler will be inserted in the loop below.
#features=[equivalence_tracker, gof.DestroyHandler(do_imports_on_attach=False)])
#features=[equivalence_tracker, gof.DestroyHandler(do_imports_on_attach=False)])
features
=
[
equivalence_tracker
])
features
=
[
equivalence_tracker
])
...
@@ -687,6 +692,13 @@ def _optcheck_fgraph(input_specs, output_specs, accept_inplace=False):
...
@@ -687,6 +692,13 @@ def _optcheck_fgraph(input_specs, output_specs, accept_inplace=False):
if
getattr
(
node
.
op
,
'destroy_map'
,
None
):
if
getattr
(
node
.
op
,
'destroy_map'
,
None
):
raise
TypeError
(
"Graph must not contain inplace operations"
,
raise
TypeError
(
"Graph must not contain inplace operations"
,
node
)
node
)
else
:
# However, if some inplace ops are already in the graph,
# DestroyHandler is needed for the Supervisor below to work correctly.
for
node
in
fgraph
.
apply_nodes
:
if
getattr
(
node
.
op
,
'destroy_map'
,
None
):
fgraph
.
attach_feature
(
gof
.
DestroyHandler
())
break
# We need to protect all immutable inputs from inplace operations.
# We need to protect all immutable inputs from inplace operations.
fgraph
.
attach_feature
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
inputs
)
fgraph
.
attach_feature
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
inputs
)
...
...
theano/compile/function_module.py
浏览文件 @
bbc25bc6
...
@@ -141,7 +141,12 @@ def std_fgraph(input_specs, output_specs, accept_inplace = False):
...
@@ -141,7 +141,12 @@ def std_fgraph(input_specs, output_specs, accept_inplace = False):
break
break
# We need to protect all immutable inputs from inplace operations.
# We need to protect all immutable inputs from inplace operations.
fgraph
.
attach_feature
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
inputs
)
if
not
(
spec
.
mutable
or
(
hasattr
(
fgraph
,
'destroyers'
)
and
fgraph
.
destroyers
(
input
)))))
fgraph
.
attach_feature
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
inputs
)
if
not
(
spec
.
mutable
or
(
hasattr
(
fgraph
,
'destroyers'
)
and
fgraph
.
destroyers
(
input
)))))
# If named nodes are replaced, keep the name
# If named nodes are replaced, keep the name
for
feature
in
std_fgraph
.
features
:
for
feature
in
std_fgraph
.
features
:
...
...
theano/gof/opt.py
浏览文件 @
bbc25bc6
...
@@ -1411,13 +1411,17 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1411,13 +1411,17 @@ class EquilibriumOptimizer(NavigatorOptimizer):
max_use_abort
=
False
max_use_abort
=
False
opt_name
=
None
opt_name
=
None
process_count
=
{}
process_count
=
{}
max_nb_nodes
=
0
max_nb_nodes
=
len
(
fgraph
.
apply_nodes
)
max_use
=
max_nb_nodes
*
self
.
max_use_ratio
loop_timing
=
[]
loop_timing
=
[]
global_opt_timing
=
[]
global_opt_timing
=
[]
time_lopts
=
{}
time_lopts
=
{}
io_toposort_timing
=
[]
io_toposort_timing
=
[]
nb_nodes
=
[]
nb_nodes
=
[]
for
gopt
in
self
.
global_optimizers
:
process_count
.
setdefault
(
gopt
,
0
)
for
lopt
in
self
.
local_optimizers
:
for
lopt
in
self
.
local_optimizers
:
process_count
.
setdefault
(
lopt
,
0
)
process_count
.
setdefault
(
lopt
,
0
)
time_lopts
.
setdefault
(
lopt
,
0
)
time_lopts
.
setdefault
(
lopt
,
0
)
...
@@ -1426,12 +1430,17 @@ class EquilibriumOptimizer(NavigatorOptimizer):
...
@@ -1426,12 +1430,17 @@ class EquilibriumOptimizer(NavigatorOptimizer):
t0
=
time
.
time
()
t0
=
time
.
time
()
changed
=
False
changed
=
False
#apply global optimizer
#apply global optimizers
fgraph
.
change_tracker
.
reset
()
for
gopt
in
self
.
global_optimizers
:
for
gopt
in
self
.
global_optimizers
:
fgraph
.
change_tracker
.
reset
()
gopt
.
apply
(
fgraph
)
gopt
.
apply
(
fgraph
)
if
fgraph
.
change_tracker
.
changed
:
if
fgraph
.
change_tracker
.
changed
:
changed
=
True
process_count
[
gopt
]
+=
1
changed
=
True
if
process_count
[
gopt
]
>
max_use
:
max_use_abort
=
True
opt_name
=
(
getattr
(
gopt
,
"name"
,
None
)
or
getattr
(
gopt
,
"__name__"
,
""
))
global_opt_timing
.
append
(
float
(
time
.
time
()
-
t0
))
global_opt_timing
.
append
(
float
(
time
.
time
()
-
t0
))
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
bbc25bc6
...
@@ -258,8 +258,8 @@ class t_gemm(TestCase):
...
@@ -258,8 +258,8 @@ class t_gemm(TestCase):
def
test_destroy_map4
(
self
):
def
test_destroy_map4
(
self
):
"""test that dot args can be aliased"""
"""test that dot args can be aliased"""
Z
=
shared
(
self
.
rand
(
2
,
2
))
Z
=
shared
(
self
.
rand
(
2
,
2
)
,
name
=
'Z'
)
A
=
shared
(
self
.
rand
(
2
,
2
))
A
=
shared
(
self
.
rand
(
2
,
2
)
,
name
=
'A'
)
one
=
T
.
constant
(
1.0
)
.
astype
(
Z
.
dtype
)
one
=
T
.
constant
(
1.0
)
.
astype
(
Z
.
dtype
)
f
=
inplace_func
([],
gemm_inplace
(
Z
,
one
,
A
,
A
,
one
))
f
=
inplace_func
([],
gemm_inplace
(
Z
,
one
,
A
,
A
,
one
))
f
()
f
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论