Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
80a81928
提交
80a81928
authored
7月 31, 2017
作者:
Pascal Lamblin
提交者:
GitHub
7月 31, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6150 from ReyhaneAskari/fix_stack_trace
Fix stack trace
上级
e89aee9d
2f673bcb
隐藏空白字符变更
内嵌
并排
正在显示
5 个修改的文件
包含
69 行增加
和
1 行删除
+69
-1
config.txt
doc/library/config.txt
+15
-0
mode.py
theano/compile/mode.py
+10
-0
configdefaults.py
theano/configdefaults.py
+12
-0
__init__.py
theano/gof/__init__.py
+1
-1
opt.py
theano/gof/opt.py
+31
-0
没有找到文件。
doc/library/config.txt
浏览文件 @
80a81928
...
...
@@ -255,6 +255,21 @@ import theano and print the config variable, as in:
not predictable, so if you are close to the peak memory usage, trying both
could give you a small gain.
.. attribute:: check_stack_trace
String value, either ``off``, ``log``, ``warn``, ``raise``
Default: ``off``
This is a flag for checking the stack trace during the optimization process.
If :attr:`check_stack_trace` is set to ``off``, no check is performed on the
stack trace. If :attr:`check_stack_trace` is set to ``log`` or ``warn``, a
dummy stack trace is inserted that indicates which optimization inserted the
variable that had an empty stack trace but, in ``warn`` a warning is also
printed.
If :attr:`check_stack_trace` is set to ``raise``, an exception is raised if a
stack trace is missing.
.. attribute:: openmp
Bool value: either ``True`` or ``False``
...
...
theano/compile/mode.py
浏览文件 @
80a81928
...
...
@@ -226,6 +226,16 @@ optdb.register('add_destroy_handler', AddDestroyHandler(),
optdb
.
register
(
'merge3'
,
gof
.
MergeOptimizer
(),
100
,
'fast_run'
,
'merge'
)
if
theano
.
config
.
check_stack_trace
in
[
'raise'
,
'warn'
,
'log'
]:
_tags
=
(
'fast_run'
,
'fast_compile'
)
if
theano
.
config
.
check_stack_trace
==
'off'
:
_tags
=
()
optdb
.
register
(
'CheckStackTrace'
,
gof
.
CheckStackTraceOptimization
(),
-
1
,
*
_tags
)
del
_tags
class
Mode
(
object
):
"""
...
...
theano/configdefaults.py
浏览文件 @
80a81928
...
...
@@ -1496,6 +1496,18 @@ AddConfigVar('cycle_detection',
EnumStr
(
'regular'
,
'fast'
),
in_c_key
=
False
)
AddConfigVar
(
'check_stack_trace'
,
"A flag for checking the stack trace during the optimization process. "
"default (off): does not check the stack trace of any optimization "
"log: inserts a dummy stack trace that identifies the optimization"
"that inserted the variable that had an empty stack trace."
"warn: prints a warning if a stack trace is missing and also a dummy"
"stack trace is inserted that indicates which optimization inserted"
"the variable that had an empty stack trace."
"raise: raises an exception if a stack trace is missing"
,
EnumStr
(
'off'
,
'log'
,
'warn'
,
'raise'
),
in_c_key
=
False
)
def
_timeout_default
():
return
theano
.
config
.
compile
.
wait
*
24
...
...
theano/gof/__init__.py
浏览文件 @
80a81928
...
...
@@ -65,7 +65,7 @@ from theano.gof.opt import (
LocalOptimizer
,
local_optimizer
,
LocalOptGroup
,
OpSub
,
OpRemove
,
PatternSub
,
NavigatorOptimizer
,
TopoOptimizer
,
EquilibriumOptimizer
,
OpKeyOptimizer
)
OpKeyOptimizer
,
CheckStackTraceOptimization
)
from
theano.gof.optdb
import
\
DB
,
LocalGroupDB
,
Query
,
\
...
...
theano/gof/opt.py
浏览文件 @
80a81928
...
...
@@ -3038,3 +3038,34 @@ def check_stack_trace(f_or_fgraph, ops_to_check='last', bug_print='raise'):
return
False
return
True
class
CheckStrackTraceFeature
(
object
):
def
on_import
(
self
,
fgraph
,
node
,
reason
):
# In optdb we only register the CheckStackTraceOptimization when
# theano.config.check_stack_trace is not off but we also double check here.
if
theano
.
config
.
check_stack_trace
!=
'off'
and
not
check_stack_trace
(
fgraph
,
'all'
):
if
theano
.
config
.
check_stack_trace
==
'raise'
:
raise
AssertionError
(
'Empty stack trace! The optimization that inserted this variable is '
+
str
(
reason
))
elif
theano
.
config
.
check_stack_trace
in
[
'log'
,
'warn'
]:
apply_nodes_to_check
=
fgraph
.
apply_nodes
for
node
in
apply_nodes_to_check
:
for
output
in
node
.
outputs
:
if
not
hasattr
(
output
.
tag
,
'trace'
)
or
not
output
.
tag
.
trace
:
output
.
tag
.
trace
=
[[(
''
,
0
,
'Empty stack trace! The optimization that'
+
'inserted this variable is '
+
str
(
reason
),
''
)]]
if
theano
.
config
.
check_stack_trace
==
'warn'
:
warnings
.
warn
(
'Empty stack trace! The optimization that inserted this variable is'
+
str
(
reason
))
class
CheckStackTraceOptimization
(
Optimizer
):
"""Optimizer that serves to add CheckStackTraceOptimization as an fgraph feature."""
def
add_requirements
(
self
,
fgraph
):
if
not
hasattr
(
fgraph
,
'CheckStrackTraceFeature'
):
fgraph
.
attach_feature
(
CheckStrackTraceFeature
())
def
apply
(
self
,
fgraph
):
pass
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论