提交 611a3d75 authored 作者: Razvan Pascanu's avatar Razvan Pascanu

clone constants only if they belong to an env ( in pfunc)

complied with suggestion given by Fred.
上级 9b3cccf0
......@@ -78,6 +78,9 @@ def rebuild_collect_shared( outputs
clone_d. Also appends all shared variables met along the way to
shared inputs, and their default_update (if applicable) to update_d
and update_expr.
v can have an env attached to it, case in which we want to clone
constants ( to avoid having a constant belonging to two envs)
'''
# this co-recurses with clone_a
assert v is not None
......@@ -108,7 +111,8 @@ def rebuild_collect_shared( outputs
, (v, v.type, v_update, v_update.type))
update_d[v] = v_update
update_expr.append((v, v_update))
if not copy_inputs_over or isinstance(v, Constant):
if not copy_inputs_over or (isinstance(v, Constant) and
hasattr(v,'env')):
### Cloning shared variables implies copying their underlying
### memory buffer ?? No.
return clone_d.setdefault(v,v.clone())
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论