提交 43320ef3 authored 作者: ChienliMa's avatar ChienliMa

swap input storage in in instances; put modification of fg.inputs outside…

swap input storage in in instances; put modification of fg.inputs outside fg.replace() cause some error occor
上级 f303478f
......@@ -635,11 +635,14 @@ class Function(object):
# swap variable and value of In instances
i.variable = swap_sv
i.value = swap_sv.container
# In the fgraph we use the cloned SharedVariable
swap_sv = swap_sv.clone()
# Swap SharedVariable in fgraph
# if inputs was replaced, change self.inputs
fg_cpy.inputs[index] = swap_sv
fg_cpy.replace(in_v, swap_sv, reason="Swap SV")
# Delete update if needed
......@@ -667,6 +670,7 @@ class Function(object):
for key in storage_map.keys():
if key not in i_o_vars:
new_storage_map[memo[key]] = storage_map[key]
if not name and self.name:
name = self.name + " copy"
......
......@@ -574,10 +574,6 @@ class FunctionGraph(utils.object2):
% (tval_shape, new_tval_shape),
r, new_r, str(reason))
# if inputs was replaced, change self.inputs
if r in self.inputs:
self.inputs[self.inputs.index(r)] = new_r
for node, i in list(r.clients): # copy the client list for iteration
assert (node == 'output' and self.outputs[i] is r) or (node.inputs[i] is r)
self.change_input(node, i, new_r, reason=reason)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论