Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7c84cbe2
提交
7c84cbe2
authored
2月 23, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debugmode - print out which of the c/py implementations was inconsistent with destroymap
上级
c4fbfa30
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
8 行增加
和
5 行删除
+8
-5
debugmode.py
theano/compile/debugmode.py
+8
-5
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
7c84cbe2
...
@@ -216,16 +216,18 @@ class BadOptimization(DebugModeError):
...
@@ -216,16 +216,18 @@ class BadOptimization(DebugModeError):
class
BadDestroyMap
(
DebugModeError
):
class
BadDestroyMap
(
DebugModeError
):
"""Exception: Some perform() or c_code() modified an input that wasn't in the destroy_map"""
"""Exception: Some perform() or c_code() modified an input that wasn't in the destroy_map"""
def
__init__
(
self
,
node
,
idx
,
old_val
,
new_val
):
def
__init__
(
self
,
node
,
idx
,
old_val
,
new_val
,
perform
):
super
(
BadDestroyMap
,
self
)
.
__init__
()
super
(
BadDestroyMap
,
self
)
.
__init__
()
self
.
node
=
node
self
.
node
=
node
self
.
idx
=
idx
self
.
idx
=
idx
self
.
old_val
=
old_val
self
.
old_val
=
old_val
self
.
new_val
=
new_val
self
.
new_val
=
new_val
self
.
perform
=
perform
def
__str__
(
self
):
def
__str__
(
self
):
sio
=
StringIO
()
sio
=
StringIO
()
print
>>
sio
,
" node:"
,
self
.
node
print
>>
sio
,
" node:"
,
self
.
node
print
>>
sio
,
" perform:"
,
self
.
perform
print
>>
sio
,
" node.inputs:"
,
[(
str
(
i
),
id
(
i
))
for
i
in
self
.
node
.
inputs
]
print
>>
sio
,
" node.inputs:"
,
[(
str
(
i
),
id
(
i
))
for
i
in
self
.
node
.
inputs
]
print
>>
sio
,
" destroy_map:"
,
getattr
(
self
.
node
.
op
,
'destroy_map'
,
{})
print
>>
sio
,
" destroy_map:"
,
getattr
(
self
.
node
.
op
,
'destroy_map'
,
{})
print
>>
sio
,
" changed input idx:"
,
self
.
idx
print
>>
sio
,
" changed input idx:"
,
self
.
idx
...
@@ -402,7 +404,8 @@ def _optcheck_env(input_specs, output_specs, accept_inplace = False):
...
@@ -402,7 +404,8 @@ def _optcheck_env(input_specs, output_specs, accept_inplace = False):
env
.
extend
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
inputs
)
if
not
(
spec
.
mutable
or
(
hasattr
(
env
,
'destroyers'
)
and
env
.
destroyers
(
input
)))))
env
.
extend
(
Supervisor
(
input
for
spec
,
input
in
zip
(
input_specs
,
inputs
)
if
not
(
spec
.
mutable
or
(
hasattr
(
env
,
'destroyers'
)
and
env
.
destroyers
(
input
)))))
return
env
,
map
(
SymbolicOutput
,
updates
),
equivalence_tracker
return
env
,
map
(
SymbolicOutput
,
updates
),
equivalence_tracker
def
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_nodes
,
clobber_dr_vals
=
True
):
def
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_nodes
,
clobber_dr_vals
=
True
,
perform
=
None
):
"""Raise BadDestroyMap if necessary, update dr_vals"""
"""Raise BadDestroyMap if necessary, update dr_vals"""
destroyed_idx_list
=
[]
destroyed_idx_list
=
[]
destroy_map
=
getattr
(
node
.
op
,
'destroy_map'
,
{})
destroy_map
=
getattr
(
node
.
op
,
'destroy_map'
,
{})
...
@@ -424,7 +427,7 @@ def _check_inputs(node, storage_map, r_vals, dr_vals, active_nodes, clobber_dr_v
...
@@ -424,7 +427,7 @@ def _check_inputs(node, storage_map, r_vals, dr_vals, active_nodes, clobber_dr_v
dr_vals
[
r
]
=
(
storage_map
[
r
][
0
],
node
)
#no copy, this is the last use of this variable
dr_vals
[
r
]
=
(
storage_map
[
r
][
0
],
node
)
#no copy, this is the last use of this variable
storage_map
[
r
][
0
]
=
None
#make sure that dr_vals[r] doens't get used again
storage_map
[
r
][
0
]
=
None
#make sure that dr_vals[r] doens't get used again
else
:
else
:
raise
BadDestroyMap
(
node
,
r_idx
,
r_vals
[
r
],
storage_map
[
r
][
0
])
raise
BadDestroyMap
(
node
,
r_idx
,
r_vals
[
r
],
storage_map
[
r
][
0
]
,
perform
)
def
_check_viewmap
(
node
,
storage_map
):
def
_check_viewmap
(
node
,
storage_map
):
...
@@ -1018,7 +1021,7 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1018,7 +1021,7 @@ class _Linker(gof.link.LocalLinker):
#if r in r_vals:
#if r in r_vals:
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_order_set
,
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_order_set
,
clobber_dr_vals
=
True
)
clobber_dr_vals
=
True
,
perform
=
'py'
)
_check_viewmap
(
node
,
storage_map
)
_check_viewmap
(
node
,
storage_map
)
...
@@ -1059,7 +1062,7 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1059,7 +1062,7 @@ class _Linker(gof.link.LocalLinker):
self
.
maker
.
mode
.
require_matching_strides
,
node
.
op
)
self
.
maker
.
mode
.
require_matching_strides
,
node
.
op
)
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_order_set
,
_check_inputs
(
node
,
storage_map
,
r_vals
,
dr_vals
,
active_order_set
,
clobber_dr_vals
=
False
)
clobber_dr_vals
=
False
,
perform
=
'c'
)
_check_viewmap
(
node
,
storage_map
)
_check_viewmap
(
node
,
storage_map
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论