未验证 提交 2967624b 编写于 作者: Z Zhang Ting 提交者: GitHub

[cherry-pick] avoid calling cast twice #30528

 cherry-pick #30527 
上级 c2a4a50e
...@@ -228,6 +228,7 @@ def cast(x, dtype): ...@@ -228,6 +228,7 @@ def cast(x, dtype):
if not isinstance(dtype, core.VarDesc.VarType): if not isinstance(dtype, core.VarDesc.VarType):
dtype = convert_np_dtype_to_dtype_(dtype) dtype = convert_np_dtype_to_dtype_(dtype)
out = core.ops.cast(x, 'in_dtype', x.dtype, 'out_dtype', dtype) out = core.ops.cast(x, 'in_dtype', x.dtype, 'out_dtype', dtype)
return out
check_variable_and_dtype( check_variable_and_dtype(
x, 'x', x, 'x',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册