Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
65ead2f5
提交
65ead2f5
authored
2月 18, 2014
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1736 from nouiz/err_msg
[MRG]Better error message when a thunk fail: print user code line when node was created
上级
f16c8763
57a5f54c
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
51 行增加
和
22 行删除
+51
-22
configdefaults.py
theano/configdefaults.py
+3
-1
link.py
theano/gof/link.py
+41
-20
utils.py
theano/gof/utils.py
+7
-1
没有找到文件。
theano/configdefaults.py
浏览文件 @
65ead2f5
...
@@ -259,7 +259,9 @@ AddConfigVar('gpuelemwise.sync',
...
@@ -259,7 +259,9 @@ AddConfigVar('gpuelemwise.sync',
AddConfigVar
(
'traceback.limit'
,
AddConfigVar
(
'traceback.limit'
,
"The number of stack to trace. -1 mean all."
,
"The number of stack to trace. -1 mean all."
,
IntParam
(
5
),
# We default to 6 to be able to know where v1 + v2 is created in the
# user script. The bigger this number is, the more run time it takes.
IntParam
(
6
),
in_c_key
=
False
)
in_c_key
=
False
)
AddConfigVar
(
'experimental.mrg'
,
AddConfigVar
(
'experimental.mrg'
,
...
...
theano/gof/link.py
浏览文件 @
65ead2f5
...
@@ -56,14 +56,14 @@ sys.excepthook = thunk_hook
...
@@ -56,14 +56,14 @@ sys.excepthook = thunk_hook
# TODO: Make this work with linker defined schedule
# TODO: Make this work with linker defined schedule
def
raise_with_op
(
op
,
thunk
=
None
,
exc_info
=
None
):
def
raise_with_op
(
node
,
thunk
=
None
,
exc_info
=
None
):
"""
"""
Re-raise an exception while annotating the exception object with
Re-raise an exception while annotating the exception object with
debug info.
debug info.
Parameters
Parameters
----------
----------
op
: Apply node
node
: Apply node
The Apply node object that resulted in the raised exception.
The Apply node object that resulted in the raised exception.
exc_info : tuple, optional
exc_info : tuple, optional
A tuple containing the exception type, exception object and
A tuple containing the exception type, exception object and
...
@@ -94,16 +94,16 @@ def raise_with_op(op, thunk=None, exc_info=None):
...
@@ -94,16 +94,16 @@ def raise_with_op(op, thunk=None, exc_info=None):
# print a simple traceback from KeyboardInterrupt
# print a simple traceback from KeyboardInterrupt
raise
exc_type
,
exc_value
,
exc_trace
raise
exc_type
,
exc_value
,
exc_trace
try
:
try
:
trace
=
op
.
tag
.
trace
trace
=
node
.
tag
.
trace
except
AttributeError
:
except
AttributeError
:
try
:
try
:
trace
=
op
.
op
.
tag
.
trace
trace
=
node
.
op
.
tag
.
trace
except
AttributeError
:
except
AttributeError
:
trace
=
()
trace
=
()
exc_value
.
__thunk_trace__
=
trace
exc_value
.
__thunk_trace__
=
trace
exc_value
.
__op_instance__
=
op
exc_value
.
__op_instance__
=
node
if
op
in
op
.
fgraph
.
toposort
():
if
node
in
node
.
fgraph
.
toposort
():
exc_value
.
__applynode_index__
=
op
.
fgraph
.
toposort
()
.
index
(
op
)
exc_value
.
__applynode_index__
=
node
.
fgraph
.
toposort
()
.
index
(
node
)
else
:
else
:
exc_value
.
__applynode_index__
=
None
exc_value
.
__applynode_index__
=
None
...
@@ -112,7 +112,11 @@ def raise_with_op(op, thunk=None, exc_info=None):
...
@@ -112,7 +112,11 @@ def raise_with_op(op, thunk=None, exc_info=None):
if
raise_with_op
.
print_thunk_trace
:
if
raise_with_op
.
print_thunk_trace
:
log_thunk_trace
(
exc_value
)
log_thunk_trace
(
exc_value
)
detailed_err_msg
=
"
\n
Apply node that caused the error: "
+
str
(
op
)
hints
=
[]
detailed_err_msg
=
"
\n
Apply node that caused the error: "
+
str
(
node
)
types
=
[
getattr
(
ipt
,
'type'
,
'No type'
)
for
ipt
in
node
.
inputs
]
detailed_err_msg
+=
"
\n
Inputs types:
%
s
\n
"
%
types
if
thunk
is
not
None
:
if
thunk
is
not
None
:
if
hasattr
(
thunk
,
'inputs'
):
if
hasattr
(
thunk
,
'inputs'
):
...
@@ -131,26 +135,43 @@ def raise_with_op(op, thunk=None, exc_info=None):
...
@@ -131,26 +135,43 @@ def raise_with_op(op, thunk=None, exc_info=None):
strides
=
"So we can't access the strides of inputs values"
strides
=
"So we can't access the strides of inputs values"
scalar_values
=
"And can't print its inputs scalar value"
scalar_values
=
"And can't print its inputs scalar value"
types
=
[
getattr
(
ipt
,
'type'
,
'No type'
)
detailed_err_msg
+=
(
"Inputs shapes:
%
s"
%
shapes
+
for
ipt
in
op
.
inputs
]
detailed_err_msg
+=
(
"
\n
Inputs shapes:
%
s"
%
shapes
+
"
\n
Inputs strides:
%
s"
%
strides
+
"
\n
Inputs strides:
%
s"
%
strides
+
"
\n
Inputs types:
%
s"
%
types
+
"
\n
Inputs scalar values:
%
s
\n
"
%
scalar_values
)
"
\n
Inputs scalar values:
%
s"
%
scalar_values
)
else
:
hints
.
append
(
"HINT: Use another linker then the c linker to"
" have the inputs shapes and strides printed."
)
# Print node backtrace
tr
=
getattr
(
node
.
tag
,
'trace'
,
None
)
if
tr
:
sio
=
StringIO
.
StringIO
()
traceback
.
print_list
(
tr
,
sio
)
tr
=
sio
.
getvalue
()
detailed_err_msg
+=
"
\n
Backtrace when the node is created:"
detailed_err_msg
+=
str
(
tr
)
else
:
else
:
detailed_err_msg
+=
(
"
\n
Use another linker then the c linker to"
hints
.
append
(
" have the inputs shapes and strides printed."
)
"HINT: Re-running with most Theano optimization disabled could"
" give you a back-traces when this node was created. This can"
" be done with by setting the Theano flags"
" optimizer=fast_compile"
)
if
theano
.
config
.
exception_verbosity
==
'high'
:
if
theano
.
config
.
exception_verbosity
==
'high'
:
f
=
StringIO
.
StringIO
()
f
=
StringIO
.
StringIO
()
theano
.
printing
.
debugprint
(
op
,
file
=
f
,
stop_on_name
=
True
,
theano
.
printing
.
debugprint
(
node
,
file
=
f
,
stop_on_name
=
True
,
print_type
=
True
)
print_type
=
True
)
detailed_err_msg
+=
"
\n
Debugprint of the apply node:
\n
"
+
f
.
getvalue
()
detailed_err_msg
+=
"
\n
Debugprint of the apply node:
\n
"
detailed_err_msg
+=
f
.
getvalue
()
else
:
else
:
detailed_err_msg
+=
(
"
\n
Use the Theano flag 'exception_verbosity=high'"
hints
.
append
(
" for a debugprint of this apply node."
)
"HINT: Use the Theano flag 'exception_verbosity=high'"
" for a debugprint of this apply node."
)
exc_value
=
exc_type
(
str
(
exc_value
)
+
detailed_err_msg
)
exc_value
=
exc_type
(
str
(
exc_value
)
+
detailed_err_msg
+
'
\n
'
+
'
\n
'
.
join
(
hints
))
raise
exc_type
,
exc_value
,
exc_trace
raise
exc_type
,
exc_value
,
exc_trace
raise_with_op
.
print_thunk_trace
=
False
raise_with_op
.
print_thunk_trace
=
False
...
...
theano/gof/utils.py
浏览文件 @
65ead2f5
...
@@ -12,7 +12,13 @@ def add_tag_trace(thing):
...
@@ -12,7 +12,13 @@ def add_tag_trace(thing):
limit
=
config
.
traceback
.
limit
limit
=
config
.
traceback
.
limit
if
limit
==
-
1
:
if
limit
==
-
1
:
limit
=
None
limit
=
None
thing
.
tag
.
trace
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
tr
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
# Different python version use different sementic for
# limit. python 2.7 include the call to extrack_stack. The -1 get
# rid of it. We also want to get rid of the add_tag_trace call.
if
tr
and
"add_tag_trace"
in
tr
[
-
1
][
-
1
]:
tr
=
tr
[:
-
1
]
thing
.
tag
.
trace
=
tr
return
thing
return
thing
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论