未验证 提交 c00a5dec 编写于 作者: W Wu Yi 提交者: GitHub

Merge pull request #9644 from typhoonzero/fix_condition_op_in_optimize

Fix transpiler condition op in optimize
...@@ -408,11 +408,7 @@ class DistributeTranspiler: ...@@ -408,11 +408,7 @@ class DistributeTranspiler:
pserver_vars = pserver_program.global_block().vars pserver_vars = pserver_program.global_block().vars
created_var_map = dict() created_var_map = dict()
for _, var in pserver_vars.iteritems(): for _, var in pserver_vars.iteritems():
tmpvar = s_prog.global_block().create_var( tmpvar = s_prog.global_block().clone_variable(var)
name=var.name,
persistable=var.persistable,
dtype=var.dtype,
shape=var.shape)
created_var_map[var.name] = tmpvar created_var_map[var.name] = tmpvar
# 2. rename op outputs # 2. rename op outputs
...@@ -708,11 +704,7 @@ class DistributeTranspiler: ...@@ -708,11 +704,7 @@ class DistributeTranspiler:
varlist = [varlist] varlist = [varlist]
for var in varlist: for var in varlist:
program.global_block().create_var( program.global_block().clone_variable(var)
name=var.name,
persistable=var.persistable,
dtype=var.dtype,
shape=var.shape)
optimize_block.append_op( optimize_block.append_op(
type=opt_op.type, type=opt_op.type,
......
...@@ -946,13 +946,20 @@ class Block(object): ...@@ -946,13 +946,20 @@ class Block(object):
The new variable cloned from 'var' in current block. The new variable cloned from 'var' in current block.
""" """
assert isinstance(var, Variable) assert isinstance(var, Variable)
return self.create_var( ret_var = None
name=var.name, # make STEP_SCOPES var can be safely cloned.
shape=var.shape, if var.type == core.VarDesc.VarType.STEP_SCOPES:
dtype=var.dtype, ret_var = self.create_var(
type=var.type, name=var.name, persistable=var.persistable, type=var.type)
lod_level=var.lod_level, else:
persistable=True) ret_var = self.create_var(
name=var.name,
shape=var.shape,
dtype=var.dtype,
type=var.type,
lod_level=var.lod_level,
persistable=True)
return ret_var
class Program(object): class Program(object):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册