Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
35df45e1
提交
35df45e1
authored
2月 18, 2016
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4079 from nouiz/stack_trace
better stack trace handling.
上级
e5f414f4
0f23609e
显示空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
59 行增加
和
47 行删除
+59
-47
function.py
theano/compile/function.py
+2
-0
link.py
theano/gof/link.py
+1
-1
test_utils.py
theano/gof/tests/test_utils.py
+15
-0
utils.py
theano/gof/utils.py
+41
-46
没有找到文件。
theano/compile/function.py
浏览文件 @
35df45e1
...
@@ -120,6 +120,8 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
...
@@ -120,6 +120,8 @@ def function(inputs, outputs=None, mode=None, updates=None, givens=None,
profile: None, True, or ProfileStats instance
profile: None, True, or ProfileStats instance
Accumulate profiling information into a given ProfileStats instance.
Accumulate profiling information into a given ProfileStats instance.
If argument is `True` then a new ProfileStats instance will be used.
If argument is `True` then a new ProfileStats instance will be used.
If argument is a string, a new ProfileStats instance will be created
with that string as its ``message`` attribute.
This profiling object will be available via self.profile.
This profiling object will be available via self.profile.
on_unused_input
on_unused_input
What to do if a variable in the 'inputs' list is not used in the graph.
What to do if a variable in the 'inputs' list is not used in the graph.
...
...
theano/gof/link.py
浏览文件 @
35df45e1
...
@@ -169,7 +169,7 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
...
@@ -169,7 +169,7 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
# Print node backtraces
# Print node backtraces
tr
=
getattr
(
node
.
outputs
[
0
]
.
tag
,
'trace'
,
[])
tr
=
getattr
(
node
.
outputs
[
0
]
.
tag
,
'trace'
,
[])
if
type
(
tr
)
is
list
and
len
(
tr
)
>
0
:
if
type
(
tr
)
is
list
and
len
(
tr
)
>
0
:
detailed_err_msg
+=
"
\n
Backtrace when the node is created:
\n
"
detailed_err_msg
+=
"
\n
Backtrace when the node is created
(use Theano flag traceback.limit=N to make it longer)
:
\n
"
# Print separate message for each element in the list of batcktraces
# Print separate message for each element in the list of batcktraces
sio
=
StringIO
()
sio
=
StringIO
()
...
...
theano/gof/tests/test_utils.py
浏览文件 @
35df45e1
...
@@ -62,3 +62,18 @@ def test_hash_from_dict():
...
@@ -62,3 +62,18 @@ def test_hash_from_dict():
# List are not hashable. So they are transformed into tuple.
# List are not hashable. So they are transformed into tuple.
assert
hash_from_dict
({
0
:
(
0
,)})
==
hash_from_dict
({
0
:
[
0
]})
assert
hash_from_dict
({
0
:
(
0
,)})
==
hash_from_dict
({
0
:
[
0
]})
def
test_stack_trace
():
orig
=
theano
.
config
.
traceback
.
limit
try
:
theano
.
config
.
traceback
.
limit
=
1
v
=
theano
.
tensor
.
vector
()
assert
len
(
v
.
tag
.
trace
)
==
1
assert
len
(
v
.
tag
.
trace
[
0
])
==
1
theano
.
config
.
traceback
.
limit
=
2
v
=
theano
.
tensor
.
vector
()
assert
len
(
v
.
tag
.
trace
)
==
1
assert
len
(
v
.
tag
.
trace
[
0
])
==
2
finally
:
theano
.
config
.
traceback
.
limit
=
orig
theano/gof/utils.py
浏览文件 @
35df45e1
from
__future__
import
print_function
from
__future__
import
print_function
import
linecache
import
linecache
import
traceback
import
sys
import
sys
import
numpy
import
numpy
...
@@ -10,14 +9,20 @@ from theano import config
...
@@ -10,14 +9,20 @@ from theano import config
from
theano.compat
import
OrderedDict
,
PY3
from
theano.compat
import
OrderedDict
,
PY3
def
simple_extract_stack
(
f
=
None
,
limit
=
None
):
def
simple_extract_stack
(
f
=
None
,
limit
=
None
,
skips
=
[]):
"""
"""This is traceback.extract_stack from python 2.7 with this change:
This is traceback.extract_stack from python 2.7 with this change:
- Comment the update of the cache.
- Comment the update of the cache.
- Skip internal stack trace level.
The update of the cache call os.stat to verify is the cache is up
to date. This take too much time on cluster.
limit - The number of stack level we want to return. If None, mean
all what we can.
This is because this update cause an call to os.stat to get the
skips - partial path of stack level we don't want to keep and count.
line content. This cause too much long on cluster
.
When we find one level that isn't skipped, we stop skipping
.
"""
"""
if
f
is
None
:
if
f
is
None
:
...
@@ -28,7 +33,7 @@ def simple_extract_stack(f=None, limit=None):
...
@@ -28,7 +33,7 @@ def simple_extract_stack(f=None, limit=None):
if
limit
is
None
:
if
limit
is
None
:
if
hasattr
(
sys
,
'tracebacklimit'
):
if
hasattr
(
sys
,
'tracebacklimit'
):
limit
=
sys
.
tracebacklimit
limit
=
sys
.
tracebacklimit
list
=
[]
trace
=
[]
n
=
0
n
=
0
while
f
is
not
None
and
(
limit
is
None
or
n
<
limit
):
while
f
is
not
None
and
(
limit
is
None
or
n
<
limit
):
lineno
=
f
.
f_lineno
lineno
=
f
.
f_lineno
...
@@ -41,20 +46,28 @@ def simple_extract_stack(f=None, limit=None):
...
@@ -41,20 +46,28 @@ def simple_extract_stack(f=None, limit=None):
line
=
line
.
strip
()
line
=
line
.
strip
()
else
:
else
:
line
=
None
line
=
None
list
.
append
((
filename
,
lineno
,
name
,
line
))
f
=
f
.
f_back
f
=
f
.
f_back
n
=
n
+
1
list
.
reverse
()
return
list
if
sys
.
version_info
[:
2
]
>
(
3
,
4
):
# Just skip inner level
# I enable my implementation only for some python version just to
if
len
(
trace
)
==
0
:
# be sure the Python internal do not change. If this work with
rm
=
False
# other python version, you can enable it.
for
p
in
skips
:
simple_extract_stack
=
traceback
.
extract_stack
# noqa
# Julian: I added the 'tests' exception together with
# Arnaud. Otherwise, we'd lose the stack trace during
# in our test cases (e.g. in test_opt.py). We're not
# sure this is the right way to do it though.
if
p
in
filename
and
'tests'
not
in
filename
:
rm
=
True
break
if
rm
:
continue
trace
.
append
((
filename
,
lineno
,
name
,
line
))
n
=
n
+
1
trace
.
reverse
()
return
trace
def
add_tag_trace
(
thing
,
user_line
=
1
):
def
add_tag_trace
(
thing
,
user_line
=
None
):
"""
"""
Add tag.trace to an node or variable.
Add tag.trace to an node or variable.
...
@@ -73,42 +86,24 @@ def add_tag_trace(thing, user_line=1):
...
@@ -73,42 +86,24 @@ def add_tag_trace(thing, user_line=1):
we look.
we look.
"""
"""
limit
=
config
.
traceback
.
limit
if
user_line
is
None
:
if
limit
==
-
1
:
user_line
=
config
.
traceback
.
limit
limit
=
None
tr
=
simple_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.
# Get rid of Theano internal
if
user_line
==
-
1
:
while
tr
:
user_line
=
None
file_path
=
tr
[
-
1
][
0
]
skips
=
[
"theano/tensor/"
,
"theano
\\
tensor
\\
"
,
rm
=
False
for
p
in
[
"theano/tensor/"
,
"theano
\\
tensor
\\
"
,
"theano/compile/"
,
"theano
\\
compile
\\
"
,
"theano/compile/"
,
"theano
\\
compile
\\
"
,
"theano/gof/"
,
"theano
\\
gof
\\
"
,
"theano/gof/"
,
"theano
\\
gof
\\
"
,
"theano/scalar/basic.py"
,
"theano
\\
scalar
\\
basic.py"
,
"theano/scalar/basic.py"
,
"theano
\\
scalar
\\
basic.py"
,
"theano/sandbox/"
,
"theano
\\
sandbox
\\
"
,
"theano/sandbox/"
,
"theano
\\
sandbox
\\
"
,
"theano/scan_module/"
,
"theano
\\
scan_module
\\
"
,
"theano/scan_module/"
,
"theano
\\
scan_module
\\
"
,
"theano/sparse/"
,
"theano
\\
sparse
\\
"
,
"theano/sparse/"
,
"theano
\\
sparse
\\
"
,
"theano/typed_list/"
,
"theano
\\
typed_list
\\
"
,
"theano/typed_list/"
,
"theano
\\
typed_list
\\
"
]
]:
tr
=
simple_extract_stack
(
limit
=
user_line
,
skips
=
skips
)
# Julian: I added the 'tests' exception together with Arnaud.
# Different python version use different sementic for
# Otherwise, we'd lose the stack trace during in our test cases
# limit. python 2.7 include the call to extrack_stack. The -1 get
# (e.g. in test_opt.py). We're not sure this is the right way to
# rid of it.
# do it though.
if
p
in
file_path
and
'tests'
not
in
file_path
:
tr
=
tr
[:
-
1
]
rm
=
True
break
if
not
rm
:
break
# Keep only the most recent stack level.
# The order is from the oldest to the newest
if
len
(
tr
)
>
user_line
:
tr
=
tr
[
-
user_line
:]
if
tr
:
if
tr
:
thing
.
tag
.
trace
=
[
tr
]
thing
.
tag
.
trace
=
[
tr
]
else
:
else
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论