Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2ee6a232
提交
2ee6a232
authored
7月 19, 2012
作者:
Olivier Delalleau
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
PEP8 fixes
上级
fb168351
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
22 行增加
和
24 行删除
+22
-24
function_module.py
theano/compile/function_module.py
+22
-24
没有找到文件。
theano/compile/function_module.py
浏览文件 @
2ee6a232
...
@@ -956,17 +956,17 @@ class FunctionMaker(object):
...
@@ -956,17 +956,17 @@ class FunctionMaker(object):
def
env_getter
(
self
):
def
env_getter
(
self
):
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
stacklevel
=
2
)
stacklevel
=
2
)
return
self
.
fgraph
return
self
.
fgraph
def
env_setter
(
self
,
value
):
def
env_setter
(
self
,
value
):
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
stacklevel
=
2
)
stacklevel
=
2
)
self
.
fgraph
=
value
self
.
fgraph
=
value
def
env_deleter
(
self
):
def
env_deleter
(
self
):
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
warnings
.
warn
(
"FunctionMaker.env is deprecated, it has been renamed 'fgraph'"
,
stacklevel
=
2
)
stacklevel
=
2
)
del
self
.
fgraph
del
self
.
fgraph
env
=
property
(
env_getter
,
env_setter
,
env_deleter
)
env
=
property
(
env_getter
,
env_setter
,
env_deleter
)
...
@@ -1035,21 +1035,19 @@ class FunctionMaker(object):
...
@@ -1035,21 +1035,19 @@ class FunctionMaker(object):
if
not
isinstance
(
inputs
,
(
list
,
tuple
)):
if
not
isinstance
(
inputs
,
(
list
,
tuple
)):
inputs
=
[
inputs
]
inputs
=
[
inputs
]
# Wrap them in In or Out instances if needed.
# Wrap them in In or Out instances if needed.
#import pudb; pudb.set_trace()
#import pudb; pudb.set_trace()
inputs
,
outputs
=
map
(
self
.
wrap_in
,
inputs
),
map
(
self
.
wrap_out
,
outputs
)
inputs
,
outputs
=
map
(
self
.
wrap_in
,
inputs
),
map
(
self
.
wrap_out
,
outputs
)
_inputs
=
gof
.
graph
.
inputs
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
_inputs
=
gof
.
graph
.
inputs
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)])
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)])
# Check if some input variables are unused
# Check if some input variables are unused
self
.
_check_unused_inputs
(
inputs
,
outputs
,
on_unused_input
)
self
.
_check_unused_inputs
(
inputs
,
outputs
,
on_unused_input
)
#TODO: REMOVE THIS CRUFT - it's complicated for SymbolicInputKits
#TODO: REMOVE THIS CRUFT - it's complicated for SymbolicInputKits
indices
=
[[
input
]
+
self
.
expand_in
(
input
,
_inputs
)
for
input
in
inputs
]
indices
=
[[
input
]
+
self
.
expand_in
(
input
,
_inputs
)
for
input
in
inputs
]
expanded_inputs
=
reduce
(
list
.
__add__
,
[
list
(
z
)
for
x
,
y
,
z
in
indices
],
[])
expanded_inputs
=
reduce
(
list
.
__add__
,
[
list
(
z
)
for
x
,
y
,
z
in
indices
],
[])
assert
expanded_inputs
==
inputs
#JB - I added this to make sure we could delete above
assert
expanded_inputs
==
inputs
#
JB - I added this to make sure we could delete above
# make the fgraph (copies the graph, creates NEW INPUT AND OUTPUT VARIABLES)
# make the fgraph (copies the graph, creates NEW INPUT AND OUTPUT VARIABLES)
fgraph
,
additional_outputs
=
std_fgraph
(
expanded_inputs
,
outputs
,
accept_inplace
)
fgraph
,
additional_outputs
=
std_fgraph
(
expanded_inputs
,
outputs
,
accept_inplace
)
...
@@ -1079,7 +1077,7 @@ class FunctionMaker(object):
...
@@ -1079,7 +1077,7 @@ class FunctionMaker(object):
_logger
.
debug
(
'Optimizing took
%
f seconds'
,
opt_time
)
_logger
.
debug
(
'Optimizing took
%
f seconds'
,
opt_time
)
#Add deep copy to respect the memory interface
#Add deep copy to respect the memory interface
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
insert_deepcopy
(
fgraph
,
inputs
,
outputs
+
additional_outputs
)
finally
:
finally
:
theano
.
config
.
compute_test_value
=
compute_test_value_orig
theano
.
config
.
compute_test_value
=
compute_test_value_orig
gof
.
Op
.
add_stack_trace_on_call
=
add_stack_trace_on_call
gof
.
Op
.
add_stack_trace_on_call
=
add_stack_trace_on_call
...
@@ -1090,10 +1088,10 @@ class FunctionMaker(object):
...
@@ -1090,10 +1088,10 @@ class FunctionMaker(object):
"or one of
%
s"
%
mode_module
.
predefined_linkers
.
keys
())
"or one of
%
s"
%
mode_module
.
predefined_linkers
.
keys
())
#the 'no_borrow' outputs are the ones for which that we can't return the internal storage pointer.
#the 'no_borrow' outputs are the ones for which that we can't return the internal storage pointer.
assert
len
(
fgraph
.
outputs
)
==
len
(
outputs
+
additional_outputs
)
assert
len
(
fgraph
.
outputs
)
==
len
(
outputs
+
additional_outputs
)
no_borrow
=
[
output
for
output
,
spec
in
zip
(
fgraph
.
outputs
,
outputs
+
additional_outputs
)
if
not
spec
.
borrow
]
no_borrow
=
[
output
for
output
,
spec
in
zip
(
fgraph
.
outputs
,
outputs
+
additional_outputs
)
if
not
spec
.
borrow
]
if
no_borrow
:
if
no_borrow
:
self
.
linker
=
linker
.
accept
(
fgraph
,
no_recycling
=
infer_reuse_pattern
(
fgraph
,
no_borrow
))
self
.
linker
=
linker
.
accept
(
fgraph
,
no_recycling
=
infer_reuse_pattern
(
fgraph
,
no_borrow
))
else
:
else
:
self
.
linker
=
linker
.
accept
(
fgraph
)
self
.
linker
=
linker
.
accept
(
fgraph
)
...
@@ -1170,8 +1168,8 @@ class FunctionMaker(object):
...
@@ -1170,8 +1168,8 @@ class FunctionMaker(object):
"""
"""
if
input_storage
is
None
:
if
input_storage
is
None
:
input_storage
=
[
None
]
*
len
(
self
.
inputs
)
input_storage
=
[
None
]
*
len
(
self
.
inputs
)
input_storage_lists
=
[]
# list of independent one-element lists, will be passed to the linker
input_storage_lists
=
[]
# list of independent one-element lists, will be passed to the linker
defaults
=
[]
defaults
=
[]
# The following loop is to fill in the input_storage_lists and defaults lists.
# The following loop is to fill in the input_storage_lists and defaults lists.
...
@@ -1224,11 +1222,9 @@ class FunctionMaker(object):
...
@@ -1224,11 +1222,9 @@ class FunctionMaker(object):
refeed
,
refeed
,
storage
))
storage
))
# Get a function instance
# Get a function instance
start_linker
=
time
.
time
()
start_linker
=
time
.
time
()
_fn
,
_i
,
_o
=
self
.
linker
.
make_thunk
(
input_storage
=
input_storage_lists
)
_fn
,
_i
,
_o
=
self
.
linker
.
make_thunk
(
input_storage
=
input_storage_lists
)
end_linker
=
time
.
time
()
end_linker
=
time
.
time
()
linker_time
=
end_linker
-
start_linker
linker_time
=
end_linker
-
start_linker
...
@@ -1238,30 +1234,30 @@ class FunctionMaker(object):
...
@@ -1238,30 +1234,30 @@ class FunctionMaker(object):
self
.
profile
.
linker_time
+=
linker_time
self
.
profile
.
linker_time
+=
linker_time
_fn
.
time_thunks
=
self
.
profile
.
flag_time_thunks
_fn
.
time_thunks
=
self
.
profile
.
flag_time_thunks
fn
=
self
.
function_builder
(
_fn
,
_i
,
_o
,
self
.
indices
,
self
.
outputs
,
fn
=
self
.
function_builder
(
_fn
,
_i
,
_o
,
self
.
indices
,
self
.
outputs
,
defaults
,
self
.
unpack_single
,
self
.
return_none
,
self
)
defaults
,
self
.
unpack_single
,
self
.
return_none
,
self
)
fn
.
profile
=
self
.
profile
fn
.
profile
=
self
.
profile
return
fn
return
fn
def
_pickle_FunctionMaker
(
self
):
def
_pickle_FunctionMaker
(
self
):
kwargs
=
dict
(
kwargs
=
dict
(
inputs
=
self
.
inputs
,
inputs
=
self
.
inputs
,
outputs
=
self
.
orig_outputs
,
outputs
=
self
.
orig_outputs
,
mode
=
self
.
mode
,
mode
=
self
.
mode
,
accept_inplace
=
self
.
accept_inplace
,
accept_inplace
=
self
.
accept_inplace
,
function_builder
=
self
.
function_builder
,
function_builder
=
self
.
function_builder
,
profile
=
self
.
profile
,
profile
=
self
.
profile
,
)
)
return
(
_constructor_FunctionMaker
,
(
kwargs
,))
return
(
_constructor_FunctionMaker
,
(
kwargs
,))
def
_constructor_FunctionMaker
(
kwargs
):
def
_constructor_FunctionMaker
(
kwargs
):
return
FunctionMaker
(
**
kwargs
)
return
FunctionMaker
(
**
kwargs
)
copy_reg
.
pickle
(
FunctionMaker
,
_pickle_FunctionMaker
)
copy_reg
.
pickle
(
FunctionMaker
,
_pickle_FunctionMaker
)
try
:
try
:
# Pickle of slice is implemented on python 2.6. To enabled be
# Pickle of slice is implemented on python 2.6. To enabled be
# compatible with python 2.4, we implement pickling of slice
# compatible with python 2.4, we implement pickling of slice
...
@@ -1276,6 +1272,7 @@ except TypeError:
...
@@ -1276,6 +1272,7 @@ except TypeError:
__checkers
=
[]
__checkers
=
[]
def
check_equal
(
x
,
y
):
def
check_equal
(
x
,
y
):
for
checker
in
__checkers
:
for
checker
in
__checkers
:
try
:
try
:
...
@@ -1285,6 +1282,7 @@ def check_equal(x, y):
...
@@ -1285,6 +1282,7 @@ def check_equal(x, y):
return
x
==
y
return
x
==
y
#raise Exception('No checker for equality between %s and %s' % (x, y))
#raise Exception('No checker for equality between %s and %s' % (x, y))
def
register_checker
(
checker
):
def
register_checker
(
checker
):
__checkers
.
insert
(
0
,
checker
)
__checkers
.
insert
(
0
,
checker
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论