Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
357723ed
提交
357723ed
authored
3月 17, 2008
作者:
Olivier Breuleux
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added op traceback support to PerformLinker
上级
cb772e00
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
24 行增加
和
38 行删除
+24
-38
_test_link.py
gof/_test_link.py
+1
-1
link.py
gof/link.py
+23
-37
没有找到文件。
gof/_test_link.py
浏览文件 @
357723ed
...
@@ -130,7 +130,7 @@ class _test_PerformLinker(unittest.TestCase):
...
@@ -130,7 +130,7 @@ class _test_PerformLinker(unittest.TestCase):
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
...
...
gof/link.py
浏览文件 @
357723ed
...
@@ -13,40 +13,17 @@ def thunk_hook(type, value, trace):
...
@@ -13,40 +13,17 @@ def thunk_hook(type, value, trace):
if
len
(
value
.
args
)
>
0
and
hasattr
(
value
[
0
],
'__thunk_trace__'
):
if
len
(
value
.
args
)
>
0
and
hasattr
(
value
[
0
],
'__thunk_trace__'
):
# such a hack :(
# such a hack :(
trace2
=
value
[
0
]
.
__thunk_trace__
#.exc_info
trace2
=
value
[
0
]
.
__thunk_trace__
#.exc_info
print
>>
sys
.
stderr
,
"Definition in: "
if
trace2
is
None
:
for
line
in
traceback
.
format_list
(
trace2
):
print
>>
sys
.
stderr
,
"Could not find where this Op was defined."
print
>>
sys
.
stderr
,
line
,
print
>>
sys
.
stderr
,
" * You might have instantiated this Op directly instead of using a constructor."
print
>>
sys
.
stderr
,
" * The Op you constructed might have been optimized. Try turning off optimizations."
elif
trace2
:
print
>>
sys
.
stderr
,
"Definition in: "
for
line
in
traceback
.
format_list
(
trace2
):
print
>>
sys
.
stderr
,
line
,
__excepthook
(
type
,
value
,
trace
)
__excepthook
(
type
,
value
,
trace
)
sys
.
excepthook
=
thunk_hook
sys
.
excepthook
=
thunk_hook
class
Thunk
:
def
__init__
(
self
):
self
.
results
=
None
self
.
is_valid
=
False
self
.
exc_info
=
()
self
.
inputs
=
[]
self
.
outputs
=
[]
def
call_thunk
(
self
):
raise
AbstractFunctionError
def
exc_print
(
self
,
f
=
sys
.
stderr
):
if
self
.
is_valid
:
return
type
,
value
,
trace
=
self
.
exc_info
for
line
in
traceback
.
format_list
(
trace
):
print
>>
f
,
line
,
print
>>
f
,
traceback
.
format_exception_only
(
type
,
value
)
def
call_thunk_and_raise
(
self
):
self
.
call_thunk
()
if
not
self
.
is_valid
:
type
,
value
,
trace
=
self
.
exc_info
raise
self
.
type
,
self
.
value
def
__call__
(
self
,
*
inputs
):
raise
AbstractFunctionError
class
Linker
:
class
Linker
:
...
@@ -124,13 +101,22 @@ class PerformLinker(Linker):
...
@@ -124,13 +101,22 @@ class PerformLinker(Linker):
order
=
env
.
toposort
()
order
=
env
.
toposort
()
thunks
=
[
op
.
perform
for
op
in
order
]
thunks
=
[
op
.
perform
for
op
in
order
]
def
f
():
def
f
():
for
thunk
in
thunks
:
try
:
thunk
()
for
thunk
,
op
in
zip
(
thunks
,
order
):
return
f
,
env
.
inputs
,
env
.
outputs
thunk
()
except
:
try
:
trace
=
op
.
trace
except
AttributeError
:
trace
=
()
exc_type
,
exc_value
,
exc_trace
=
sys
.
exc_info
()
class
X
:
pass
__x
=
X
()
__x
.
__thunk_trace__
=
trace
__x
.
__str__
=
lambda
:
str
(
exc_value
)
+
" (in op: "
+
str
(
op
)
+
")"
raise
exc_type
,
__x
,
exc_trace
# self.thunk = f
return
f
,
env
.
inputs
,
env
.
outputs
# self.order = order
# self.thunks = thunks
class
ProfilePerformLinker
(
Linker
):
class
ProfilePerformLinker
(
Linker
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论