Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5960a4ea
提交
5960a4ea
authored
8月 16, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
function_module - extended the logic that un-aliases input/output variables
上级
36b147ea
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
34 行增加
和
6 行删除
+34
-6
function_module.py
theano/compile/function_module.py
+34
-6
没有找到文件。
theano/compile/function_module.py
浏览文件 @
5960a4ea
...
@@ -751,13 +751,19 @@ class FunctionMaker(object):
...
@@ -751,13 +751,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()
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
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)])
_inputs
=
gof
.
graph
.
inputs
([
o
.
variable
for
o
in
outputs
]
+
[
i
.
update
for
i
in
inputs
if
getattr
(
i
,
'update'
,
False
)])
#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
# make the env
# make the env
(copies the graph, creates NEW INPUT AND OUTPUT VARIABLES)
env
,
additional_outputs
=
std_env
(
expanded_inputs
,
outputs
,
accept_inplace
)
env
,
additional_outputs
=
std_env
(
expanded_inputs
,
outputs
,
accept_inplace
)
self
.
env
=
env
self
.
env
=
env
...
@@ -774,12 +780,34 @@ class FunctionMaker(object):
...
@@ -774,12 +780,34 @@ class FunctionMaker(object):
# but some of the outputs can be shared variables, and is not good for shared
# but some of the outputs can be shared variables, and is not good for shared
# variables to be aliased. It might be possible to optimize this by making sure
# variables to be aliased. It might be possible to optimize this by making sure
# there is no aliasing only between shared variables.
# there is no aliasing only between shared variables.
assert
len
(
inputs
)
==
len
(
env
.
inputs
)
updated_env_inputs
=
[
env_i
for
i
,
env_i
in
zip
(
inputs
,
env
.
inputs
)
if
getattr
(
i
,
'update'
,
False
)]
for
i
in
xrange
(
len
(
env
.
outputs
)):
for
i
in
xrange
(
len
(
env
.
outputs
)):
views
=
set
()
views_of_output_i
=
set
()
view_tree_set
(
alias_root
(
env
.
outputs
[
i
]),
views
)
view_tree_set
(
alias_root
(
env
.
outputs
[
i
]),
views_of_output_i
)
copied
=
False
# do not allow outputs to be aliased
for
j
in
xrange
(
i
+
1
,
len
(
env
.
outputs
)):
for
j
in
xrange
(
i
+
1
,
len
(
env
.
outputs
)):
if
env
.
outputs
[
j
]
in
views
:
if
env
.
outputs
[
j
]
in
views_of_output_i
:
env
.
change_input
(
'output'
,
j
,
deep_copy_op
(
env
.
outputs
[
j
]))
env
.
change_input
(
'output'
,
i
,
deep_copy_op
(
env
.
outputs
[
i
]))
copied
=
True
break
if
not
copied
:
for
input_j
in
env
.
inputs
:
# do not allow outputs to be aliased to an inputs (j), unless
# a) that j'th input has been 'destroyed' by e.g. in-place computations
# b) that j'th input is a shared variable that is also being updated
if
hasattr
(
env
,
'get_destroyers_of'
)
and
env
.
get_destroyers_of
(
input_j
):
continue
if
input_j
in
updated_env_inputs
:
continue
if
input_j
in
views_of_output_i
:
env
.
change_input
(
'output'
,
i
,
deep_copy_op
(
env
.
outputs
[
i
]))
break
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论