Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2046b190
提交
2046b190
authored
9月 19, 2011
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix pydotprint in ProfileMode.
上级
95778c8f
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
18 行增加
和
13 行删除
+18
-13
printing.py
theano/printing.py
+12
-13
test_printing.py
theano/tests/test_printing.py
+6
-0
没有找到文件。
theano/printing.py
浏览文件 @
2046b190
...
...
@@ -382,7 +382,8 @@ pprint.assign(lambda pstate, r: hasattr(pstate, 'target') and pstate.target is n
pp
=
pprint
# colors not used: orange, ambre#FFBF00, purple, pink,
# used by default: green, bug, grey, red
default_colorCodes
=
{
'GpuFromHost'
:
'red'
,
'HostFromGpu'
:
'red'
,
'Scan'
:
'yellow'
,
...
...
@@ -391,8 +392,6 @@ default_colorCodes = {'GpuFromHost' : 'red',
'Elemwise'
:
'#FFAABB'
,
'Subtensor'
:
'#FFAAFF'
}
def
pydotprint
(
fct
,
outfile
=
None
,
compact
=
True
,
format
=
'png'
,
with_ids
=
False
,
high_contrast
=
True
,
cond_highlight
=
None
,
colorCodes
=
None
,
...
...
@@ -428,15 +427,15 @@ def pydotprint(fct, outfile=None,
we will print only the variable name.
Otherwise, we concatenate the type to the var name.
In the graph,
box are an Apply Node(the execution of an op) and ellipse
are variable.
In the graph,
ellipse are an Apply Node(the execution of an op) and box
are variable.
If variable have name they are used as the text(if multiple var have the same name, they will be merged in the graph).
Otherwise, if the variable is constant, we print the value and finaly we print the type + an uniq number to don't have multiple var merged.
We print the op of the apply in the Apply box with a number that represent the toposort order of application of those Apply.
If an Apply have more then 1 input, print add a label to the edge that in the index of the inputs.
green
ellipses
are inputs to the graph
blue
ellipses
are outputs of the graph
grey
ellipses
are var generated by the graph that are not output and are not used.
green
box
are inputs to the graph
blue
box
are outputs of the graph
grey
box
are var generated by the graph that are not output and are not used.
red ellipses are transfer to/from the gpu.
op with those name GpuFromHost, HostFromGpu
"""
...
...
@@ -450,7 +449,7 @@ def pydotprint(fct, outfile=None,
if
isinstance
(
fct
,
Function
):
mode
=
fct
.
maker
.
mode
fct_env
=
fct
.
maker
.
env
if
not
isinstance
(
mode
,
ProfileMode
)
or
not
mode
.
fct_call
.
has_key
(
fct
):
if
not
isinstance
(
mode
,
ProfileMode
)
or
not
mode
.
profile_stats
.
has_key
(
fct
):
mode
=
None
elif
isinstance
(
fct
,
gof
.
Env
):
mode
=
None
...
...
@@ -542,14 +541,14 @@ def pydotprint(fct, outfile=None,
return
apply_name_cache
[
node
]
prof_str
=
''
if
mode
:
time
=
mode
.
apply_time
.
get
((
topo
.
index
(
node
),
node
)
,
0
)
time
=
mode
.
profile_stats
[
fct
]
.
apply_time
.
get
(
node
,
0
)
#second, % total time in profiler, %fct time in profiler
if
mode
.
local_time
[
0
]
==
0
:
if
mode
.
local_time
==
0
:
pt
=
0
else
:
pt
=
time
*
100
/
mode
.
local_time
[
0
]
if
mode
.
fct_call
[
fct
]
==
0
:
else
:
pt
=
time
*
100
/
mode
.
local_time
if
mode
.
profile_stats
[
fct
]
.
fct_callcount
==
0
:
pf
=
0
else
:
pf
=
time
*
100
/
mode
.
fct_call_time
[
fct
]
else
:
pf
=
time
*
100
/
mode
.
profile_stats
[
fct
]
.
fct_call_time
prof_str
=
' (
%.3
fs,
%.3
f
%%
,
%.3
f
%%
)'
%
(
time
,
pt
,
pf
)
applystr
=
str
(
node
.
op
)
.
replace
(
':'
,
'_'
)
applystr
+=
prof_str
...
...
theano/tests/test_printing.py
浏览文件 @
2046b190
...
...
@@ -36,6 +36,12 @@ def test_pydotprint_cond_highlight():
assert
s
.
getvalue
()
==
'pydotprint: cond_highlight is set but there is no IfElse node in the graph
\n
'
def
test_pydotprint_profile
():
""" Just check that pydotprint don't crash with ProfileMode"""
A
=
tensor
.
matrix
()
f
=
theano
.
function
([
A
],
A
+
1
,
mode
=
'ProfileMode'
)
theano
.
printing
.
pydotprint
(
f
)
def
test_min_informative_str
():
""" evaluates a reference output to make sure the
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论