diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index dcd5495dc1a80e236a7151ef71688678a759d74a..cd0d652af849507804ae98d2e26e28b2268fe6ff 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -228,6 +228,7 @@ def cast(x, dtype): if not isinstance(dtype, core.VarDesc.VarType): dtype = convert_np_dtype_to_dtype_(dtype) out = core.ops.cast(x, 'in_dtype', x.dtype, 'out_dtype', dtype) + return out check_variable_and_dtype( x, 'x',