Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
599d6376
提交
599d6376
authored
6月 12, 2015
作者:
ChienliMa
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add assertion in map_storage to assert storage given by input/output_storage and…
Add assertion in map_storage to assert storage given by input/output_storage and storage_map is the same.
上级
cbdb4315
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
28 行增加
和
9 行删除
+28
-9
function_module.py
theano/compile/function_module.py
+10
-3
link.py
theano/gof/link.py
+18
-6
没有找到文件。
theano/compile/function_module.py
浏览文件 @
599d6376
...
@@ -560,9 +560,9 @@ class Function(object):
...
@@ -560,9 +560,9 @@ class Function(object):
share_memory -- { boolean } Default is False. When True, two
share_memory -- { boolean } Default is False. When True, two
function share intermediate storages(storages except input and
function share intermediate storages(storages except input and
output storages). Otherwise two function will only share partial
output storages). Otherwise two function will only share partial
storages( see method __copy__() )
. If two functions share memory
storages( see method __copy__() )
and same maker. If two functions
and allow_gc=False, this will increase executing speed and save
share memory and allow_gc=False, this will increase executing speed
memory.
and save
memory.
---------------------
---------------------
Returns:
Returns:
func -- Copied theano.Function
func -- Copied theano.Function
...
@@ -611,6 +611,13 @@ class Function(object):
...
@@ -611,6 +611,13 @@ class Function(object):
storage
=
getattr
(
in_cpy
,
'value'
,
None
)
storage
=
getattr
(
in_cpy
,
'value'
,
None
)
input_storage
.
append
(
storage
)
input_storage
.
append
(
storage
)
# pop out input_storage in storage_map and only use storage of In
# instances to initialize the make, so that we can avoid
# storage conflictions in link.map_storage()
assert
len
(
fg_cpy
.
inputs
)
==
len
(
input_storage
)
for
in_var
in
fg_cpy
.
inputs
:
new_storage_map
.
pop
(
in_var
)
# reinitialize new maker and create new function
# reinitialize new maker and create new function
return
maker
.
__class__
(
inputs
=
ins
,
outputs
=
maker
.
outputs
,
return
maker
.
__class__
(
inputs
=
ins
,
outputs
=
maker
.
outputs
,
fgraph
=
fg_cpy
,
fgraph
=
fg_cpy
,
...
...
theano/gof/link.py
浏览文件 @
599d6376
...
@@ -539,18 +539,24 @@ def map_storage(fgraph, order, input_storage, output_storage, storage_map=None):
...
@@ -539,18 +539,24 @@ def map_storage(fgraph, order, input_storage, output_storage, storage_map=None):
"""
"""
# each Apply argument's data is stored in a list of length 1 (these lists act like pointers)
# each Apply argument's data is stored in a list of length 1 (these lists act like pointers)
if
storage_map
is
None
:
storage_map
=
{}
# input_storage is a list of data-containers for the inputs.
# input_storage is a list of data-containers for the inputs.
if
input_storage
is
None
:
if
input_storage
is
None
:
input_storage
=
[[
None
]
for
input
in
fgraph
.
inputs
]
input_storage
=
[[
None
]
for
input
in
fgraph
.
inputs
]
else
:
else
:
assert
len
(
fgraph
.
inputs
)
==
len
(
input_storage
)
assert
len
(
fgraph
.
inputs
)
==
len
(
input_storage
)
if
storage_map
is
None
:
storage_map
=
{}
# add input storage into storage_map
# add input storage into storage_map
for
r
,
storage
in
zip
(
fgraph
.
inputs
,
input_storage
):
for
r
,
storage
in
zip
(
fgraph
.
inputs
,
input_storage
):
storage_map
[
r
]
=
storage
if
r
in
storage_map
:
assert
storage_map
[
r
]
is
storage
,
(
"Given input_storage conflicts with storage in given"
"storage_map. Given input_storage: "
,
storage
,
"Storage in storage_map: "
,
storage_map
[
r
])
else
:
storage_map
[
r
]
=
storage
# for orphan in fgraph.orphans:
# for orphan in fgraph.orphans:
# if not isinstance(orphan, Constant):
# if not isinstance(orphan, Constant):
# raise TypeError("Cannot link a graph with non-constant orphans.", orphan)
# raise TypeError("Cannot link a graph with non-constant orphans.", orphan)
...
@@ -559,8 +565,14 @@ def map_storage(fgraph, order, input_storage, output_storage, storage_map=None):
...
@@ -559,8 +565,14 @@ def map_storage(fgraph, order, input_storage, output_storage, storage_map=None):
# allocate output storage
# allocate output storage
if
output_storage
is
not
None
:
if
output_storage
is
not
None
:
assert
len
(
fgraph
.
outputs
)
==
len
(
output_storage
)
assert
len
(
fgraph
.
outputs
)
==
len
(
output_storage
)
for
r
,
storage
in
izip
(
fgraph
.
outputs
,
output_storage
):
for
r
,
storage
in
zip
(
fgraph
.
outputs
,
output_storage
):
storage_map
[
r
]
=
storage
if
r
in
storage_map
:
assert
storage_map
[
r
]
is
storage
,
(
"Given output_storage conflicts with storage in given"
"storage_map. Given output_storage: "
,
storage
,
"Storage in storage_map: "
,
storage_map
[
r
])
else
:
storage_map
[
r
]
=
storage
# allocate storage for intermediate computation
# allocate storage for intermediate computation
for
node
in
order
:
for
node
in
order
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论