Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1a6a0dbd
提交
1a6a0dbd
authored
8月 16, 2011
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2 from dwf/raise_with_op_fix_and_docstring
Remove annoying raise_with_op behaviour, document.
上级
6ee70beb
cefc5553
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
38 行增加
和
7 行删除
+38
-7
link.py
theano/gof/link.py
+38
-7
没有找到文件。
theano/gof/link.py
浏览文件 @
1a6a0dbd
...
...
@@ -33,8 +33,37 @@ def thunk_hook(type, value, trace):
sys
.
excepthook
=
thunk_hook
def
raise_with_op
(
op
,
exc_info
=
None
):
"""WRITEME"""
def
raise_with_op
(
op
,
exc_info
=
None
):
"""
Re-raise an exception while annotating the exception object with
debug info.
Parameters
----------
op : object
The Op object that resulted in the raised exception.
exc_info : tuple, optional
A tuple containing the exception type, exception object and
associated traceback, as would be returned by a call to
`sys.exc_info()` (which is done if `None` is passed).
Notes
-----
This re-raises the exception described by `exc_info` (or the last
one raised, if `exc_info` is omitted) and annotates the exception
object with several new members which may be helpful for debugging
Theano graphs. They are:
* __op_instance__: The Op that is responsible for the exception
being raised.
* __thunk_trace__: A traceback corresponding to the code that
actually generated the exception, if it is available.
* __applynode_index__: The index of the Apply node corresponding
to this op in `op.env.toposort()`.
The exception is not annotated if it is of type `KeyboardInterrupt`.
"""
if
exc_info
is
None
:
exc_info
=
sys
.
exc_info
()
exc_type
,
exc_value
,
exc_trace
=
exc_info
...
...
@@ -46,9 +75,11 @@ def raise_with_op(op, exc_info = None):
except
AttributeError
:
trace
=
()
exc_value
.
__thunk_trace__
=
trace
exc_value
.
args
+=
(
op
,
)
exc_value
.
__op_instance__
=
op
if
op
in
op
.
env
.
toposort
():
exc_value
.
args
+=
(
'Sequence id of Apply node='
+
str
(
op
.
env
.
toposort
()
.
index
(
op
)),)
exc_value
.
__applynode_index__
=
op
.
env
.
toposort
()
.
index
(
op
)
else
:
exc_value
.
__applynode_index__
=
None
raise
exc_type
,
exc_value
,
exc_trace
...
...
@@ -283,7 +314,7 @@ def streamline(env, thunks, order, post_thunk_old_storage = None, no_recycling =
thunk
()
for
old_s
in
old_storage
:
old_s
[
0
]
=
None
except
Exception
:
except
:
raise_with_op
(
node
)
f
=
streamline_default_f
elif
nice_errors
:
...
...
@@ -294,7 +325,7 @@ def streamline(env, thunks, order, post_thunk_old_storage = None, no_recycling =
try
:
for
thunk
,
node
in
thunk_node_list
:
thunk
()
except
Exception
:
except
:
raise_with_op
(
node
)
f
=
streamline_nice_errors_f
else
:
...
...
@@ -554,7 +585,7 @@ class WrapLinker(Linker):
for
i
,
(
thunks
,
node
)
in
enumerate
(
zip
(
thunk_groups
,
order
)):
try
:
wrapper
(
i
,
node
,
*
thunks
)
except
Exception
:
except
:
raise_with_op
(
node
)
f
.
thunk_groups
=
thunk_groups
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论