Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
aa07dc65
提交
aa07dc65
authored
1月 17, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added profile linker
上级
b7c8449c
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
38 行增加
和
8 行删除
+38
-8
compile.py
compile.py
+38
-8
没有找到文件。
compile.py
浏览文件 @
aa07dc65
import
time
import
gof
import
gof
import
core
import
opt
import
opt
from
copy
import
copy
from
copy
import
copy
#prog(inputs, outputs)
class
profile_linker
:
#single(*outputs)
def
__init__
(
self
,
env
):
#multi(*output_lists)
self
.
order
=
env
.
toposort
()
self
.
thunks
=
[
op
.
_perform
for
op
in
self
.
order
]
self
.
n_calls
=
0
self
.
times
=
[
0.0
for
op
in
self
.
order
]
def
__call__
(
self
):
for
i
,
thunk
in
enumerate
(
self
.
thunks
):
start_time
=
time
.
time
()
thunk
()
self
.
times
[
i
]
+=
time
.
time
()
-
start_time
self
.
n_calls
+=
1
def
dump
(
self
):
total_time
=
sum
(
self
.
times
)
print
self
.
n_calls
,
'calls took'
,
total_time
,
'seconds'
print
'Proportion of CPU per op'
for
op
,
t
in
zip
(
self
.
order
,
self
.
times
):
s_op
=
str
(
op
)
.
split
()[
0
][
1
:]
print
"
%-35
s
%4.5
f"
%
(
s_op
,
t
/
total_time
)
print
'Proportion of CPU per op class'
dct
=
{}
for
op
,
t
in
zip
(
self
.
order
,
self
.
times
):
s_op
=
str
(
op
)
.
split
()[
0
][
1
:]
dct
[
s_op
]
=
dct
.
get
(
s_op
,
0.0
)
+
t
for
t
,
s_op
in
reversed
(
sorted
([(
t
,
op
)
for
op
,
t
in
dct
.
items
()])):
print
"
%-35
s
%4.5
f"
%
(
s_op
,
t
/
total_time
)
import
core
class
prog
(
gof
.
Prog
):
class
prog
(
gof
.
Prog
):
def
__init__
(
self
,
inputs
,
outputs
,
optimizer
=
opt
.
optimizer
([])):
def
__init__
(
self
,
inputs
,
outputs
,
optimizer
=
opt
.
optimizer
([]),
linker
=
gof
.
link
.
perform_linker
):
"""Compile a subgraph.
"""Compile a subgraph.
N.B. This triggers computation of the subgraph leading to the outputs
N.B. This triggers computation of the subgraph leading to the outputs
...
@@ -26,7 +56,7 @@ class prog(gof.Prog):
...
@@ -26,7 +56,7 @@ class prog(gof.Prog):
inputs
,
inputs
,
outputs
,
outputs
,
optimizer
,
optimizer
,
gof
.
link
.
perform_
linker
,
linker
,
[])
[])
self
.
compute_orphans
()
self
.
compute_orphans
()
...
@@ -65,6 +95,6 @@ def to_func(inputs, outputs):
...
@@ -65,6 +95,6 @@ def to_func(inputs, outputs):
return
outputs
return
outputs
return
f
return
f
def
single
(
*
outputs
):
def
single
(
*
outputs
,
**
kwargs
):
return
prog
(
gof
.
graph
.
inputs
(
outputs
),
outputs
)
return
prog
(
gof
.
graph
.
inputs
(
outputs
),
outputs
,
**
kwargs
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论