Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
51f375bf
提交
51f375bf
authored
12月 18, 2014
作者:
carriepl
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2292 from ballasn/memoutput
Output StorageMap content in raise_with_op
上级
c166a9e7
4df20428
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
50 行增加
和
16 行删除
+50
-16
function_module.py
theano/compile/function_module.py
+5
-3
link.py
theano/gof/link.py
+35
-2
vm.py
theano/gof/vm.py
+10
-11
没有找到文件。
theano/compile/function_module.py
浏览文件 @
51f375bf
...
@@ -602,13 +602,15 @@ class Function(object):
...
@@ -602,13 +602,15 @@ class Function(object):
# For the CVM
# For the CVM
gof
.
link
.
raise_with_op
(
gof
.
link
.
raise_with_op
(
self
.
fn
.
nodes
[
self
.
fn
.
position_of_error
],
self
.
fn
.
nodes
[
self
.
fn
.
position_of_error
],
self
.
fn
.
thunks
[
self
.
fn
.
position_of_error
])
self
.
fn
.
thunks
[
self
.
fn
.
position_of_error
],
storage_map
=
self
.
fn
.
storage_map
)
else
:
else
:
# For the c linker We don't have access from
# For the c linker We don't have access from
# python to all the temps values So for now, we
# python to all the temps values So for now, we
# just don't print the extra shapes/strides info
# just don't print the extra shapes/strides info
gof
.
vm
.
raise_with_op
(
gof
.
link
.
raise_with_op
(
self
.
fn
.
nodes
[
self
.
fn
.
position_of_error
])
self
.
fn
.
nodes
[
self
.
fn
.
position_of_error
],
storage_map
=
self
.
fn
.
storage_map
)
else
:
else
:
# old-style linkers raise their own exceptions
# old-style linkers raise their own exceptions
raise
raise
...
...
theano/gof/link.py
浏览文件 @
51f375bf
"""WRITEME"""
"""WRITEME"""
from
copy
import
copy
,
deepcopy
from
copy
import
copy
,
deepcopy
from
sys
import
getsizeof
import
StringIO
import
StringIO
import
sys
import
sys
import
traceback
import
traceback
import
numpy
import
theano
import
theano
from
theano.gof
import
utils
from
theano.gof
import
utils
...
@@ -58,7 +60,7 @@ sys.excepthook = thunk_hook
...
@@ -58,7 +60,7 @@ sys.excepthook = thunk_hook
# TODO: Make this work with linker defined schedule
# TODO: Make this work with linker defined schedule
def
raise_with_op
(
node
,
thunk
=
None
,
exc_info
=
None
):
def
raise_with_op
(
node
,
thunk
=
None
,
exc_info
=
None
,
storage_map
=
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.
...
@@ -71,6 +73,9 @@ def raise_with_op(node, thunk=None, exc_info=None):
...
@@ -71,6 +73,9 @@ def raise_with_op(node, thunk=None, exc_info=None):
A tuple containing the exception type, exception object and
A tuple containing the exception type, exception object and
associated traceback, as would be returned by a call to
associated traceback, as would be returned by a call to
`sys.exc_info()` (which is done if `None` is passed).
`sys.exc_info()` (which is done if `None` is passed).
storage_map: dict, optional
storage map of the theano function that resulted in the
raised exception.
Notes
Notes
-----
-----
...
@@ -162,16 +167,44 @@ def raise_with_op(node, thunk=None, exc_info=None):
...
@@ -162,16 +167,44 @@ def raise_with_op(node, thunk=None, exc_info=None):
" Theano optimizations can be disabled with 'optimizer=None'."
)
" Theano optimizations can be disabled with 'optimizer=None'."
)
if
theano
.
config
.
exception_verbosity
==
'high'
:
if
theano
.
config
.
exception_verbosity
==
'high'
:
f
=
StringIO
.
StringIO
()
f
=
StringIO
.
StringIO
()
theano
.
printing
.
debugprint
(
node
,
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
"
detailed_err_msg
+=
"
\n
Debugprint of the apply node:
\n
"
detailed_err_msg
+=
f
.
getvalue
()
detailed_err_msg
+=
f
.
getvalue
()
# Prints output_map
if
storage_map
is
not
None
:
detailed_err_msg
+=
"
\n
Storage map footprint:
\n
"
for
k
in
storage_map
.
keys
():
if
storage_map
[
k
][
0
]
is
not
None
:
detailed_err_msg
+=
" - "
+
str
(
k
)
+
", "
shapeinfo
=
None
if
hasattr
(
storage_map
[
k
][
0
],
'shape'
):
shapeinfo
=
storage_map
[
k
][
0
]
.
shape
if
len
(
shapeinfo
)
!=
0
:
detailed_err_msg
+=
"Shape:
%
s, "
%
str
(
shapeinfo
)
else
:
detailed_err_msg
+=
"Shape: (1,), "
if
hasattr
(
storage_map
[
k
][
0
],
'dtype'
):
dtype
=
storage_map
[
k
][
0
]
.
dtype
detailed_err_msg
+=
"ElemSize:
%
s Byte(s)"
%
numpy
.
dtype
(
dtype
)
.
itemsize
if
shapeinfo
is
None
:
detailed_err_msg
+=
"
\n
"
else
:
detailed_err_msg
+=
", TotalSize:
%
s Byte(s)
\n
"
%
(
numpy
.
dtype
(
dtype
)
.
itemsize
*
numpy
.
prod
(
shapeinfo
))
else
:
bytes
=
getsizeof
(
storage_map
[
k
][
0
])
detailed_err_msg
+=
"ElemSize:
%
s Byte(s)
\n
"
%
str
(
bytes
)
else
:
else
:
hints
.
append
(
hints
.
append
(
"HINT: Use the Theano flag 'exception_verbosity=high'"
"HINT: Use the Theano flag 'exception_verbosity=high'"
" for a debugprint of this apply node."
)
" for a debugprint and storage map footprint 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
))
'
\n
'
+
'
\n
'
.
join
(
hints
))
...
...
theano/gof/vm.py
浏览文件 @
51f375bf
...
@@ -52,9 +52,6 @@ AddConfigVar('vm.lazy',
...
@@ -52,9 +52,6 @@ AddConfigVar('vm.lazy',
ConfigParam
(
'None'
,
filter_vm_lazy
),
ConfigParam
(
'None'
,
filter_vm_lazy
),
in_c_key
=
False
)
in_c_key
=
False
)
raise_with_op
=
link
.
raise_with_op
class
VM
(
object
):
class
VM
(
object
):
"""
"""
...
@@ -180,7 +177,7 @@ class Loop(VM):
...
@@ -180,7 +177,7 @@ class Loop(VM):
self
.
call_counts
[
i
]
+=
1
self
.
call_counts
[
i
]
+=
1
self
.
call_times
[
i
]
+=
t1
-
t0
self
.
call_times
[
i
]
+=
t1
-
t0
except
:
except
:
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
else
:
else
:
for
cont
in
self
.
pre_call_clear
:
for
cont
in
self
.
pre_call_clear
:
cont
[
0
]
=
None
cont
[
0
]
=
None
...
@@ -188,7 +185,7 @@ class Loop(VM):
...
@@ -188,7 +185,7 @@ class Loop(VM):
for
thunk
,
node
in
zip
(
self
.
thunks
,
self
.
nodes
):
for
thunk
,
node
in
zip
(
self
.
thunks
,
self
.
nodes
):
thunk
()
thunk
()
except
:
except
:
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
class
LoopGC
(
VM
):
class
LoopGC
(
VM
):
...
@@ -222,7 +219,7 @@ class LoopGC(VM):
...
@@ -222,7 +219,7 @@ class LoopGC(VM):
old_s
[
0
]
=
None
old_s
[
0
]
=
None
i
+=
1
i
+=
1
except
:
except
:
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
else
:
else
:
for
cont
in
self
.
pre_call_clear
:
for
cont
in
self
.
pre_call_clear
:
cont
[
0
]
=
None
cont
[
0
]
=
None
...
@@ -233,7 +230,7 @@ class LoopGC(VM):
...
@@ -233,7 +230,7 @@ class LoopGC(VM):
for
old_s
in
old_storage
:
for
old_s
in
old_storage
:
old_s
[
0
]
=
None
old_s
[
0
]
=
None
except
:
except
:
raise_with_op
(
node
,
thunk
)
link
.
raise_with_op
(
node
,
thunk
)
class
Stack
(
VM
):
class
Stack
(
VM
):
...
@@ -425,8 +422,9 @@ class Stack(VM):
...
@@ -425,8 +422,9 @@ class Stack(VM):
st
=
"c"
st
=
"c"
self
.
variable_strides
[
var
]
=
st
self
.
variable_strides
[
var
]
=
st
except
Exception
:
except
Exception
:
raise_with_op
(
current_apply
,
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]])
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
=
storage_map
)
for
o
in
current_apply
.
outputs
:
for
o
in
current_apply
.
outputs
:
compute_map
[
o
][
0
]
=
1
compute_map
[
o
][
0
]
=
1
...
@@ -494,8 +492,9 @@ class Stack(VM):
...
@@ -494,8 +492,9 @@ class Stack(VM):
self
.
call_times
[
current_idx
]
+=
dt
self
.
call_times
[
current_idx
]
+=
dt
except
Exception
:
except
Exception
:
raise_with_op
(
current_apply
,
link
.
raise_with_op
(
current_apply
,
self
.
thunks
[
self
.
node_idx
[
current_apply
]])
self
.
thunks
[
self
.
node_idx
[
current_apply
]],
storage_map
)
if
requires
:
if
requires
:
for
r
in
requires
:
for
r
in
requires
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论