Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fc332ccd
提交
fc332ccd
authored
9月 15, 2017
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix a test in DebugMode by makeing _Maker reuse its parent class create method.…
Fix a test in DebugMode by makeing _Maker reuse its parent class create method. The sub-version don't seem to add anything useful.
上级
9ec11732
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
6 行增加
和
89 行删除
+6
-89
debugmode.py
theano/compile/debugmode.py
+6
-89
没有找到文件。
theano/compile/debugmode.py
浏览文件 @
fc332ccd
...
...
@@ -2323,95 +2323,12 @@ class _Maker(FunctionMaker): # inheritance buys a few helper functions
self
.
output_keys
=
output_keys
self
.
name
=
name
def
create
(
self
,
input_storage
=
None
,
trustme
=
False
,
storage_map
=
None
):
"""
Create a function.
Parameters
----------
input_storage
A list matching the inputs list and providing default values if the
default for an input is None, then that input is a required input.
For an input with an update, the default acts as initialization.
trustme
Disables some exceptions, used internally.
"""
if
input_storage
is
None
:
input_storage
=
[
None
]
*
len
(
self
.
inputs
)
# List of independent one-element lists, will be passed to the linker.
input_storage_list
=
[]
_defaults
=
[]
# The following loop is to fill in the input_storage_list and _defaults
# lists.
for
(
input
,
indices
,
subinputs
),
default
in
izip
(
self
.
indices
,
input_storage
):
__default
=
default
if
isinstance
(
default
,
gof
.
Container
):
# If the default is a gof.Container, this means we want to
# share the same storage. This is done by appending
# default.storage to input_storage_list.
if
indices
is
not
None
:
raise
TypeError
(
"Cannot take a Container instance as "
"default for a SymbolicInput."
)
input_storage_list
.
append
(
default
.
storage
)
default
=
None
else
:
# Normal case: one new, independent storage unit
input_storage_list
.
append
([
None
])
# Filling _defaults. Each entry is a tuple of three elements:
# (required, refeed, value)
# - required means that the user must provide a value when calling
# the function
# - refeed means that we want to put the default back in the
# storage after each function call
# - value is the value that will be put in the storage initially
if
input
.
update
is
not
None
:
# If the input has an update, then (logically) it is
# not required since it is just a parameter and of
# course we don't want to refeed the default back into
# the storage as it would defeat the point of updating
# it. We always do this policy.
if
default
is
None
:
if
trustme
or
isinstance
(
__default
,
gof
.
Container
):
_defaults
.
append
((
False
,
False
,
None
))
else
:
# This might catch some bugs early
raise
ValueError
(
"A default (initial) value is required for an "
"input which can update itself."
,
input
)
else
:
_defaults
.
append
((
False
,
False
,
default
))
else
:
if
default
is
None
:
if
trustme
or
isinstance
(
__default
,
gof
.
Container
):
_defaults
.
append
((
False
,
False
,
None
))
else
:
# No default, so this is a required
# input. Nothing to feed back, initial value
# is None.
_defaults
.
append
((
True
,
False
,
None
))
else
:
# Default value. It is not required, but we want
# to put it back into the storage everytime so it
# behaves like most programming languages' default
# values
_defaults
.
append
((
False
,
True
,
default
))
defaults
=
_defaults
# Get a function instance
_fn
,
_i
,
_o
=
self
.
linker
.
make_thunk
(
input_storage
=
input_storage_list
,
storage_map
=
storage_map
)
fn
=
self
.
function_builder
(
_fn
,
_i
,
_o
,
self
.
indices
,
self
.
outputs
,
defaults
,
self
.
unpack_single
,
self
.
return_none
,
self
.
output_keys
,
self
,
name
=
self
.
name
)
fn
.
profile
=
self
.
profile
return
fn
self
.
required
=
[(
i
.
value
is
None
)
for
i
in
self
.
inputs
]
self
.
refeed
=
[
(
i
.
value
is
not
None
and
not
isinstance
(
i
.
value
,
gof
.
Container
)
and
i
.
update
is
None
)
for
i
in
self
.
inputs
]
########################
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论