提交 1616cb13 authored 作者: ChienliMa's avatar ChienliMa

Modify link.map_storage() so that it make use of given storage_map

上级 82e09e85
...@@ -496,10 +496,17 @@ class Container(object): ...@@ -496,10 +496,17 @@ class Container(object):
return r return r
def map_storage(fgraph, order, input_storage, output_storage):
""" def map_storage(fgraph, order, input_storage, output_storage, storage_map = None):
Ensure there is storage (a length-1 list) for inputs, outputs, and """Ensure there is storage (a length-1 list) for inputs, outputs, and interior nodes.
interior nodes.
:param fgraph: The current fgraph. This function uses the inputs and outputs attributes.
:param order: an iterable over Apply instances (in program running order)
:param input_storage: None or existing input storage (see below)
:param output_storage: None or existing output storage (see below)
:rtype: 3-tuple
:returns: (list of storage for inputs, list of storage for outputs, and the `storage_map`)
Parameters Parameters
---------- ----------
...@@ -538,8 +545,9 @@ def map_storage(fgraph, order, input_storage, output_storage): ...@@ -538,8 +545,9 @@ def map_storage(fgraph, order, input_storage, output_storage):
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)
storage_map = {} 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):
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论