Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
82d4e9a7
提交
82d4e9a7
authored
6月 19, 2015
作者:
carriepl
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2909 from aalmah/ticket_2347
improving debugprint for scan ops
上级
a94497b2
def89798
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
62 行增加
和
23 行删除
+62
-23
debugmode.py
theano/compile/debugmode.py
+31
-13
printing.py
theano/printing.py
+31
-10
test_printing.py
theano/tests/test_printing.py
+0
-0
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
82d4e9a7
...
...
@@ -25,8 +25,7 @@ from theano.configparser import (config, AddConfigVar, BoolParam, IntParam,
StrParam
)
from
theano.compile.function_module
import
(
FunctionMaker
,
Function
,
infer_reuse_pattern
,
SymbolicInputKit
,
SymbolicOutput
,
Supervisor
,
std_fgraph
)
SymbolicInputKit
,
SymbolicOutput
,
Supervisor
,
std_fgraph
)
from
theano.compile.mode
import
Mode
,
register_mode
from
theano.compile.ops
import
OutputGuard
...
...
@@ -521,7 +520,8 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
file
=
sys
.
stdout
,
print_destroy_map
=
False
,
print_view_map
=
False
,
order
=
None
,
ids
=
'CHAR'
,
stop_on_name
=
False
,
prefix_child
=
None
,
scan_ops
=
None
,
profile
=
None
):
scan_ops
=
None
,
profile
=
None
,
scan_inner_to_outer_inputs
=
None
):
"""Print the graph leading to `r` to given depth.
:param r: Variable instance
...
...
@@ -544,6 +544,9 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
we don't print anything below it.
:param scan_ops: Scan ops in the graph will be added inside this list
for later printing purposes.
:param scan_inner_to_outer_inputs: a dictionary mapping a scan ops
inner function inputs to the scan op inputs (outer inputs) for
printing purposes.
"""
if
depth
==
0
:
...
...
@@ -578,6 +581,7 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
elif
ids
==
""
:
id_str
=
""
done
[
obj
]
=
id_str
return
id_str
if
hasattr
(
r
.
owner
,
'op'
):
...
...
@@ -678,16 +682,30 @@ def debugprint(r, prefix='', depth=-1, done=None, print_type=False,
theano
.
scan_module
.
scan_op
.
Scan
):
scan_ops
.
append
(
i
)
debugprint
(
i
,
new_prefix
,
depth
=
depth
-
1
,
done
=
done
,
print_type
=
print_type
,
file
=
file
,
order
=
order
,
ids
=
ids
,
stop_on_name
=
stop_on_name
,
prefix_child
=
new_prefix_child
,
scan_ops
=
scan_ops
,
profile
=
profile
)
debugprint
(
i
,
new_prefix
,
depth
=
depth
-
1
,
done
=
done
,
print_type
=
print_type
,
file
=
file
,
order
=
order
,
ids
=
ids
,
stop_on_name
=
stop_on_name
,
prefix_child
=
new_prefix_child
,
scan_ops
=
scan_ops
,
profile
=
profile
,
scan_inner_to_outer_inputs
=
scan_inner_to_outer_inputs
)
else
:
# this is an input variable
id_str
=
get_id_str
(
r
)
print
(
'
%
s
%
s
%
s
%
s'
%
(
prefix
,
r
,
id_str
,
type_str
),
file
=
file
)
if
scan_inner_to_outer_inputs
is
not
None
and
\
r
in
scan_inner_to_outer_inputs
:
id_str
=
get_id_str
(
r
)
outer_r
=
scan_inner_to_outer_inputs
[
r
]
if
hasattr
(
outer_r
.
owner
,
'op'
):
outer_id_str
=
get_id_str
(
outer_r
.
owner
)
else
:
outer_id_str
=
get_id_str
(
outer_r
)
print
(
'
%
s
%
s
%
s
%
s ->
%
s'
%
(
prefix
,
r
,
id_str
,
type_str
,
outer_id_str
),
file
=
file
)
else
:
# this is an input variable
id_str
=
get_id_str
(
r
)
print
(
'
%
s
%
s
%
s
%
s'
%
(
prefix
,
r
,
id_str
,
type_str
),
file
=
file
)
return
file
...
...
@@ -1601,7 +1619,7 @@ class _VariableEquivalenceTracker(object):
r
,
debugprint
(
r
,
prefix
=
' '
,
depth
=
6
,
file
=
StringIO
(),
done
=
done
)
.
getvalue
(),
debugprint
(
new_r
,
prefix
=
' '
,
depth
=
6
,
debugprint
(
new_r
,
prefix
=
' '
,
depth
=
6
,
file
=
StringIO
(),
done
=
done
)
.
getvalue
()))
self
.
replaced_by
[
r
]
.
append
((
reason
,
new_r
))
...
...
theano/printing.py
浏览文件 @
82d4e9a7
...
...
@@ -149,6 +149,7 @@ N.B.:
file
=
_file
,
order
=
order
,
ids
=
ids
,
scan_ops
=
scan_ops
,
stop_on_name
=
stop_on_name
,
profile
=
p
)
if
len
(
scan_ops
)
>
0
:
print
(
""
,
file
=
_file
)
new_prefix
=
' >'
...
...
@@ -156,27 +157,47 @@ N.B.:
print
(
"Inner graphs of the scan ops:"
,
file
=
_file
)
for
s
in
scan_ops
:
# prepare a dict which maps the scan op's inner inputs
# to its outer inputs.
if
hasattr
(
s
.
owner
.
op
,
'fn'
):
# If the op was compiled, print the optimized version.
inner_inputs
=
s
.
owner
.
op
.
fn
.
maker
.
fgraph
.
inputs
else
:
inner_inputs
=
s
.
owner
.
op
.
inputs
outer_inputs
=
s
.
owner
.
inputs
inner_to_outer_inputs
=
\
dict
([(
inner_inputs
[
i
],
outer_inputs
[
o
])
for
i
,
o
in
s
.
owner
.
op
.
var_mappings
[
'outer_inp_from_inner_inp'
]
.
items
()])
print
(
""
,
file
=
_file
)
debugmode
.
debugprint
(
s
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
_file
,
ids
=
ids
,
scan_ops
=
scan_ops
,
stop_on_name
=
stop_on_name
)
debugmode
.
debugprint
(
s
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
_file
,
ids
=
ids
,
scan_ops
=
scan_ops
,
stop_on_name
=
stop_on_name
,
scan_inner_to_outer_inputs
=
inner_to_outer_inputs
)
if
hasattr
(
s
.
owner
.
op
,
'fn'
):
# If the op was compiled, print the optimized version.
outputs
=
s
.
owner
.
op
.
fn
.
maker
.
fgraph
.
outputs
else
:
outputs
=
s
.
owner
.
op
.
outputs
for
idx
,
i
in
enumerate
(
outputs
):
if
hasattr
(
i
,
'owner'
)
and
hasattr
(
i
.
owner
,
'op'
):
if
isinstance
(
i
.
owner
.
op
,
theano
.
scan_module
.
scan_op
.
Scan
):
scan_ops
.
append
(
i
)
debugmode
.
debugprint
(
r
=
i
,
prefix
=
new_prefix
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
_file
,
ids
=
ids
,
stop_on_name
=
stop_on_name
,
prefix_child
=
new_prefix_child
,
scan_ops
=
scan_ops
)
debugmode
.
debugprint
(
r
=
i
,
prefix
=
new_prefix
,
depth
=
depth
,
done
=
done
,
print_type
=
print_type
,
file
=
_file
,
ids
=
ids
,
stop_on_name
=
stop_on_name
,
prefix_child
=
new_prefix_child
,
scan_ops
=
scan_ops
,
scan_inner_to_outer_inputs
=
inner_to_outer_inputs
)
if
file
is
_file
:
return
file
...
...
theano/tests/test_printing.py
浏览文件 @
82d4e9a7
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论