diff --git a/python/paddle/fluid/tests/unittests/test_conj_op.py b/python/paddle/fluid/tests/unittests/test_conj_op.py index 44698f5679b2de1975ea2f596bbee891243a8fd8..b3c24ba5f0017a658320cf3490ea83aafe86b3f3 100644 --- a/python/paddle/fluid/tests/unittests/test_conj_op.py +++ b/python/paddle/fluid/tests/unittests/test_conj_op.py @@ -133,5 +133,20 @@ class TestComplexConjOp(unittest.TestCase): np.testing.assert_array_equal(result, target) +class Testfp16ConjOp(unittest.TestCase): + def testfp16(self): + input_x = ( + np.random.random((12, 14)) + 1j * np.random.random((12, 14)) + ).astype('float16') + with static.program_guard(static.Program()): + x = static.data(name="x", shape=[12, 14], dtype='float16') + out = paddle.conj(x) + if paddle.is_compiled_with_cuda(): + place = paddle.CUDAPlace(0) + exe = paddle.static.Executor(place) + exe.run(paddle.static.default_startup_program()) + out = exe.run(feed={'x': input_x}, fetch_list=[out]) + + if __name__ == "__main__": unittest.main() diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 591b885439517ed2eaf9edc2b6c82710dcca2a9a..6391bb093195742d7930a506c90bf3ee307c3da7 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -3861,7 +3861,7 @@ def conj(x, name=None): Args: x (Tensor): The input Tensor which hold the complex numbers. - Optional data types are: complex64, complex128, float32, float64, int32 or int64. + Optional data types are:float16, complex64, complex128, float32, float64, int32 or int64. name (str, optional): Name for the operation (optional, default is None). For more information, please refer to :ref:`api_guide_Name`. Returns: @@ -3889,7 +3889,15 @@ def conj(x, name=None): check_variable_and_dtype( x, "x", - ['complex64', 'complex128', 'float32', 'float64', 'int32', 'int64'], + [ + 'complex64', + 'complex128', + 'float16', + 'float32', + 'float64', + 'int32', + 'int64', + ], 'conj', )