diff --git a/python/paddle/fluid/layers/tensor.py b/python/paddle/fluid/layers/tensor.py index 987918493d3b4aa1d313403cbb1aa6ffc8c8e6e9..a62217c628c302b7bb9e3f4aa62ee6fad17cb6bc 100644 --- a/python/paddle/fluid/layers/tensor.py +++ b/python/paddle/fluid/layers/tensor.py @@ -587,7 +587,8 @@ def assign(input, output=None): # after this api. if isinstance(input, (Variable, core.VarBase)): check_dtype(input.dtype, 'input', [ - 'float16', 'uint16', 'float32', 'float64', 'int32', 'int64', 'bool' + 'float16', 'uint16', 'float32', 'float64', 'int32', 'int64', + 'uint8', 'bool' ], 'assign', '(When the type of input in assign is Variable.)') if output is None: output = helper.create_variable_for_type_inference( diff --git a/python/paddle/fluid/tests/unittests/test_assign_op.py b/python/paddle/fluid/tests/unittests/test_assign_op.py index fe82b23b73bdb23da2dc30a083ac91f94a5ed1fd..694fd3c656107f1ebaeb79042036e3566229c53b 100644 --- a/python/paddle/fluid/tests/unittests/test_assign_op.py +++ b/python/paddle/fluid/tests/unittests/test_assign_op.py @@ -90,12 +90,9 @@ class TestAssignOpError(unittest.TestCase): x1 = fluid.create_lod_tensor( np.array([[-1]]), [[1]], fluid.CPUPlace()) self.assertRaises(TypeError, fluid.layers.assign, x1) - # When the type of input is Variable, the dtype of input must be float16, float32, float64, int32, int64, bool. - x3 = fluid.layers.data(name='x3', shape=[4], dtype="uint8") - self.assertRaises(TypeError, fluid.layers.assign, x3) # When the type of input is numpy.ndarray, the dtype of input must be float32, int32. - x4 = np.array([[2.5, 2.5]], dtype='uint8') - self.assertRaises(TypeError, fluid.layers.assign, x4) + x2 = np.array([[2.5, 2.5]], dtype='uint8') + self.assertRaises(TypeError, fluid.layers.assign, x2) class TestAssignOApi(unittest.TestCase): @@ -180,12 +177,9 @@ class TestAssignOpErrorApi(unittest.TestCase): x1 = fluid.create_lod_tensor( np.array([[-1]]), [[1]], fluid.CPUPlace()) self.assertRaises(TypeError, paddle.assign, x1) - # When the type of input is Variable, the dtype of input must be float16, float32, float64, int32, int64, bool. - x3 = fluid.layers.data(name='x3', shape=[4], dtype="uint8") - self.assertRaises(TypeError, paddle.assign, x3) # When the type of input is numpy.ndarray, the dtype of input must be float32, int32. - x4 = np.array([[2.5, 2.5]], dtype='uint8') - self.assertRaises(TypeError, paddle.assign, x4) + x2 = np.array([[2.5, 2.5]], dtype='uint8') + self.assertRaises(TypeError, paddle.assign, x2) if __name__ == '__main__': diff --git a/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py b/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py index 3eefa0bce886367ad8b80f30a5bfd884ae613ded..7b74a8bb3836597dacae467e459584506979540f 100644 --- a/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py +++ b/python/paddle/fluid/tests/unittests/xpu/test_assign_op_xpu.py @@ -82,11 +82,8 @@ class TestAssignOpError(unittest.TestCase): x1 = fluid.create_lod_tensor( np.array([[-1]]), [[1]], fluid.XPUPlace(0)) self.assertRaises(TypeError, fluid.layers.assign, x1) - # When the type of input is Variable, the dtype of input must be float16, float32, float64, int32, int64, bool. - x3 = fluid.layers.data(name='x3', shape=[4], dtype="uint8") - self.assertRaises(TypeError, fluid.layers.assign, x3) - x4 = np.array([[2.5, 2.5]], dtype='uint8') - self.assertRaises(TypeError, fluid.layers.assign, x4) + x2 = np.array([[2.5, 2.5]], dtype='uint8') + self.assertRaises(TypeError, fluid.layers.assign, x2) if __name__ == '__main__':