Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9e19b7c6
提交
9e19b7c6
authored
3月 09, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Enable preallocated output checks at Mode level
That way, some instances of DebugMode can do the checks, while others do not.
上级
9fa53f44
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
26 行增加
和
4 行删除
+26
-4
debugmode.py
theano/compile/debugmode.py
+26
-4
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
9e19b7c6
...
@@ -989,6 +989,7 @@ def _find_bad_optimizations2(order, reasons, r_vals):
...
@@ -989,6 +989,7 @@ def _find_bad_optimizations2(order, reasons, r_vals):
_find_bad_optimizations
=
_find_bad_optimizations0
_find_bad_optimizations
=
_find_bad_optimizations0
def
_get_preallocated_maps
(
node
,
thunk
,
prealloc_modes
,
def_val
,
def
_get_preallocated_maps
(
node
,
thunk
,
prealloc_modes
,
def_val
,
storage_map
,
r_vals
,
dr_vals
,
perform
,
active_order_set
):
storage_map
,
r_vals
,
dr_vals
,
perform
,
active_order_set
):
'''Preallocate outputs in different memory layouts'''
'''Preallocate outputs in different memory layouts'''
...
@@ -1001,7 +1002,6 @@ def _get_preallocated_maps(node, thunk, prealloc_modes, def_val,
...
@@ -1001,7 +1002,6 @@ def _get_preallocated_maps(node, thunk, prealloc_modes, def_val,
from
theano.sandbox.cuda
import
dimshuffle
as
cuda_dimshuffle
from
theano.sandbox.cuda
import
dimshuffle
as
cuda_dimshuffle
# TODO: Sparse, Scalar
# TODO: Sparse, Scalar
# TODO: wrong shape, more stride patterns
# reuse_output: use a copy of the same storage returned the first time
# reuse_output: use a copy of the same storage returned the first time
# TODO: optimization warning if the storage in reuse_outputs
# TODO: optimization warning if the storage in reuse_outputs
...
@@ -1523,7 +1523,6 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1523,7 +1523,6 @@ class _Linker(gof.link.LocalLinker):
if
r
not
in
env
.
inputs
]
if
r
not
in
env
.
inputs
]
# Precompute some things for storage pre-allocation
# Precompute some things for storage pre-allocation
prealloc_modes
=
config
.
DebugMode
.
check_preallocated_output
.
split
(
':'
)
try
:
try
:
def_val
=
int
(
config
.
unittests
.
rseed
)
def_val
=
int
(
config
.
unittests
.
rseed
)
except
ValueError
:
except
ValueError
:
...
@@ -1656,7 +1655,9 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1656,7 +1655,9 @@ class _Linker(gof.link.LocalLinker):
# clear the storage_map of outputs for the thunk_c
# clear the storage_map of outputs for the thunk_c
storage_map
[
r
][
0
]
=
None
storage_map
[
r
][
0
]
=
None
if
config
.
DebugMode
.
check_preallocated_output
:
if
self
.
maker
.
mode
.
check_preallocated_output
:
prealloc_modes
=
\
self
.
maker
.
mode
.
check_preallocated_output
_logger
.
debug
(
_logger
.
debug
(
'
%
i - calling _check_preallocated_output '
'
%
i - calling _check_preallocated_output '
'with thunk_py'
,
i
)
'with thunk_py'
,
i
)
...
@@ -1743,7 +1744,9 @@ class _Linker(gof.link.LocalLinker):
...
@@ -1743,7 +1744,9 @@ class _Linker(gof.link.LocalLinker):
r_vals
[
r
]
=
storage_map
[
r
][
0
]
r_vals
[
r
]
=
storage_map
[
r
][
0
]
storage_map
[
r
][
0
]
=
None
#clear the storage_map for the thunk_c
storage_map
[
r
][
0
]
=
None
#clear the storage_map for the thunk_c
if
config
.
DebugMode
.
check_preallocated_output
:
if
self
.
maker
.
mode
.
check_preallocated_output
:
prealloc_modes
=
\
self
.
maker
.
mode
.
check_preallocated_output
def
thunk
():
def
thunk
():
try
:
try
:
thunk_c
()
thunk_c
()
...
@@ -2199,6 +2202,16 @@ class DebugMode(Mode):
...
@@ -2199,6 +2202,16 @@ class DebugMode(Mode):
but is generally overly strict.) 0 no check, 1 warn, 2 err.
but is generally overly strict.) 0 no check, 1 warn, 2 err.
"""
"""
check_preallocated_output
=
config
.
DebugMode
.
check_preallocated_output
check_preallocated_output
=
check_preallocated_output
.
split
(
':'
)
"""
List of strings representing ways to pre-allocate output memory in
tests. Valid values are: "previous" (previously-returned memory),
"c_contiguous", "f_contiguous", "strided" (positive and negative
strides), "wrong_size" (larger and smaller dimensions), and "ALL"
(all of the above).
"""
# This function will be used to create a FunctionMaker in
# This function will be used to create a FunctionMaker in
# function_module.function
# function_module.function
def
function_maker
(
self
,
i
,
o
,
m
,
*
args
,
**
kwargs
):
def
function_maker
(
self
,
i
,
o
,
m
,
*
args
,
**
kwargs
):
...
@@ -2214,6 +2227,7 @@ class DebugMode(Mode):
...
@@ -2214,6 +2227,7 @@ class DebugMode(Mode):
check_c_code
=
None
,
check_c_code
=
None
,
check_py_code
=
None
,
check_py_code
=
None
,
check_isfinite
=
None
,
check_isfinite
=
None
,
check_preallocated_output
=
None
,
require_matching_strides
=
None
,
require_matching_strides
=
None
,
linker
=
None
):
linker
=
None
):
...
@@ -2245,6 +2259,10 @@ class DebugMode(Mode):
...
@@ -2245,6 +2259,10 @@ class DebugMode(Mode):
if
check_isfinite
is
not
None
:
if
check_isfinite
is
not
None
:
self
.
check_isfinite
=
check_isfinite
self
.
check_isfinite
=
check_isfinite
if
check_preallocated_output
is
not
None
:
# Copy to avoid sharing the same list across different instances
self
.
check_preallocated_output
=
check_preallocated_output
[:]
if
require_matching_strides
is
not
None
:
if
require_matching_strides
is
not
None
:
self
.
require_matching_strides
=
require_matching_strides
self
.
require_matching_strides
=
require_matching_strides
...
@@ -2252,4 +2270,8 @@ class DebugMode(Mode):
...
@@ -2252,4 +2270,8 @@ class DebugMode(Mode):
raise
ValueError
(
'DebugMode has to check at least one of c and py '
raise
ValueError
(
'DebugMode has to check at least one of c and py '
'code'
)
'code'
)
def
__str__
(
self
):
return
"DebugMode(linker=
%
s, optimizer=
%
s)"
%
(
self
.
provided_linker
,
self
.
provided_optimizer
)
register_mode
(
'DEBUG_MODE'
,
DebugMode
(
optimizer
=
'fast_run'
))
register_mode
(
'DEBUG_MODE'
,
DebugMode
(
optimizer
=
'fast_run'
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论