Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5e07df51
提交
5e07df51
authored
10月 23, 2008
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added ProfileMode to sandbox/wraplinker
上级
02818b45
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
2 行删除
+53
-2
wraplinker.py
theano/sandbox/wraplinker.py
+53
-2
没有找到文件。
theano/sandbox/wraplinker.py
浏览文件 @
5e07df51
from
__future__
import
absolute_import
from
__future__
import
absolute_import
import
time
import
numpy
import
numpy
from
..gof.link
import
WrapLinker
from
..gof.link
import
WrapLinker
from
..
gradient
import
numeric_grad
from
..
compile.mode
import
Mode
class
Todo
(
Exception
):
"""todo"""
class
Todo
(
Exception
):
"""todo"""
#WrapLinker wrappers
#WrapLinker wrappers
def
cmp_outputs
(
i
,
node
,
*
thunks
):
if
0
:
from
..gradient
import
numeric_grad
def
cmp_outputs
(
i
,
node
,
*
thunks
):
"""WrapLinker wrapper: raise an exception if outputs are different
"""WrapLinker wrapper: raise an exception if outputs are different
numpy.ndarrays of floating point types are compared approximately, rather
numpy.ndarrays of floating point types are compared approximately, rather
...
@@ -98,3 +101,51 @@ def WrapLinkerMany(linkers, wrappers):
...
@@ -98,3 +101,51 @@ def WrapLinkerMany(linkers, wrappers):
def
DualLinker
(
linkers
):
def
DualLinker
(
linkers
):
return
WrapLinkerMany
(
linkers
,
[
run_all
,
cmp_outputs
])
return
WrapLinkerMany
(
linkers
,
[
run_all
,
cmp_outputs
])
class
ProfileMode
(
Mode
):
def
__init__
(
self
,
local_linker
,
optimizer
=
None
):
local_time
=
[
0.0
]
apply_time
=
{}
op_time
=
{}
def
blah
(
i
,
node
,
*
thunks
):
t0
=
time
.
time
()
for
th
in
thunks
:
th
()
dt
=
time
.
time
()
-
t0
local_time
[
0
]
+=
dt
apply_time
[(
i
,
node
.
op
)]
=
apply_time
.
get
((
i
,
node
.
op
),
0.0
)
+
dt
op_time
[
node
.
op
]
=
op_time
.
get
(
node
.
op
,
0.0
)
+
dt
self
.
local_time
=
local_time
self
.
apply_time
=
apply_time
self
.
op_time
=
op_time
linker
=
WrapLinkerMany
([
local_linker
],
[
blah
])
if
optimizer
:
Mode
.
__init__
(
self
,
linker
,
optimizer
)
else
:
Mode
.
__init__
(
self
,
linker
)
def
print_summary
(
self
):
local_time
=
self
.
local_time
[
0
]
apply_time
=
self
.
apply_time
op_time
=
self
.
op_time
print
'local_time'
,
local_time
print
'apply-wise times'
atimes
=
[(
t
/
local_time
,
(
a
[
0
],
str
(
a
[
1
])))
for
a
,
t
in
apply_time
.
items
()]
atimes
.
sort
()
atimes
.
reverse
()
for
t
,
a
in
atimes
[:
15
]:
print
' '
,
t
,
a
print
' ...'
#show that we are ignoring applies that don't take much time
print
'op-wise times'
otimes
=
[(
t
/
local_time
,
a
)
for
a
,
t
in
op_time
.
items
()]
otimes
.
sort
()
otimes
.
reverse
()
for
t
,
a
in
otimes
[:
15
]:
print
' '
,
t
,
a
print
' ...'
#show that we are ignoring applies that don't take much time
print
sum
(
t
for
a
,
t
in
op_time
.
items
())
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论