Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
3928937d
提交
3928937d
authored
10月 14, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add the new logic about not having output of theano fct being aliased to the…
add the new logic about not having output of theano fct being aliased to the inputs to the DebugMode to remove false buildbot error.
上级
f3684046
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
45 行增加
和
1 行删除
+45
-1
debugmode.py
theano/compile/debugmode.py
+45
-1
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
3928937d
...
@@ -13,12 +13,15 @@ from theano.gof.link import WrapLinkerMany, raise_with_op
...
@@ -13,12 +13,15 @@ from theano.gof.link import WrapLinkerMany, raise_with_op
from
theano.gof.cc
import
OpWiseCLinker
,
CLinker
from
theano.gof.cc
import
OpWiseCLinker
,
CLinker
from
theano.configparser
import
config
,
AddConfigVar
,
IntParam
,
BoolParam
from
theano.configparser
import
config
,
AddConfigVar
,
IntParam
,
BoolParam
from
theano.compile.function_module
import
(
FunctionMaker
,
from
theano.compile.function_module
import
(
FunctionMaker
,
alias_root
,
deep_copy_op
,
Function
,
Function
,
infer_reuse_pattern
,
infer_reuse_pattern
,
SymbolicInput
,
SymbolicInput
,
SymbolicInputKit
,
SymbolicInputKit
,
SymbolicOutput
,
SymbolicOutput
,
Supervisor
)
Supervisor
,
view_tree_set
)
from
theano.compile.mode
import
Mode
,
register_mode
from
theano.compile.mode
import
Mode
,
register_mode
AddConfigVar
(
'DebugMode.patience'
,
AddConfigVar
(
'DebugMode.patience'
,
...
@@ -1323,15 +1326,56 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
...
@@ -1323,15 +1326,56 @@ class _Maker(FunctionMaker): #inheritance buys a few helper functions
# Wrap them in In or Out instances if needed.
# Wrap them in In or Out instances if needed.
inputs
,
outputs
=
map
(
self
.
wrap_in
,
inputs
),
map
(
self
.
wrap_out
,
outputs
)
inputs
,
outputs
=
map
(
self
.
wrap_in
,
inputs
),
map
(
self
.
wrap_out
,
outputs
)
_inputs
=
gof
.
graph
.
inputs
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)])
_inputs
=
gof
.
graph
.
inputs
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)])
#TODO: REMOVE THIS CRUFT - it's complicated for SymbolicInputKits
indices
=
[[
input
]
+
self
.
expand_in
(
input
,
_inputs
)
for
input
in
inputs
]
indices
=
[[
input
]
+
self
.
expand_in
(
input
,
_inputs
)
for
input
in
inputs
]
expanded_inputs
=
reduce
(
list
.
__add__
,
[
list
(
z
)
for
x
,
y
,
z
in
indices
],
[])
expanded_inputs
=
reduce
(
list
.
__add__
,
[
list
(
z
)
for
x
,
y
,
z
in
indices
],
[])
assert
expanded_inputs
==
inputs
#JB - I added this to make sure we could delete above
# make the env
# make the env
for
i
in
xrange
(
mode
.
stability_patience
):
for
i
in
xrange
(
mode
.
stability_patience
):
env
,
additional_outputs
,
equivalence_tracker
=
_optcheck_env
(
expanded_inputs
,
outputs
,
accept_inplace
)
env
,
additional_outputs
,
equivalence_tracker
=
_optcheck_env
(
expanded_inputs
,
outputs
,
accept_inplace
)
env
.
equivalence_tracker
=
equivalence_tracker
env
.
equivalence_tracker
=
equivalence_tracker
# optimize the env
# optimize the env
optimizer
(
env
)
optimizer
(
env
)
# This loop was inserted to remove aliasing between outputs when they all
# evaluete to the same value. Originally it was OK for outputs to be aliased,
# but some of the outputs can be shared variables, and is not good for shared
# variables to be aliased. It might be possible to optimize this by making sure
# there is no aliasing only between shared variables.
#import pdb;pdb.set_trace()
assert
len
(
inputs
)
==
len
(
env
.
inputs
)
updated_env_inputs
=
[
env_i
for
i
,
env_i
in
zip
(
inputs
,
env
.
inputs
)
if
getattr
(
i
,
'update'
,
False
)]
for
i
in
xrange
(
len
(
env
.
outputs
)):
views_of_output_i
=
set
()
view_tree_set
(
alias_root
(
env
.
outputs
[
i
]),
views_of_output_i
)
copied
=
False
# do not allow outputs to be aliased
for
j
in
xrange
(
i
+
1
,
len
(
env
.
outputs
)):
if
env
.
outputs
[
j
]
in
views_of_output_i
:
#import pdb;pdb.set_trace()
env
.
change_input
(
'output'
,
i
,
deep_copy_op
(
env
.
outputs
[
i
]))
copied
=
True
break
if
not
copied
:
for
input_j
in
env
.
inputs
:
# do not allow outputs to be aliased to an inputs (j), unless
# a) that j'th input has been 'destroyed' by e.g. in-place computations
# b) that j'th input is a shared variable that is also being updated
if
hasattr
(
env
,
'get_destroyers_of'
)
and
env
.
get_destroyers_of
(
input_j
):
continue
if
input_j
in
updated_env_inputs
:
continue
if
input_j
in
views_of_output_i
:
#import pdb;pdb.set_trace()
env
.
change_input
(
'output'
,
i
,
deep_copy_op
(
env
.
outputs
[
i
]))
break
if
i
:
if
i
:
li
=
env
.
equivalence_tracker
.
event_list
li
=
env
.
equivalence_tracker
.
event_list
l0
=
env0
.
equivalence_tracker
.
event_list
l0
=
env0
.
equivalence_tracker
.
event_list
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论