diff --git a/python/paddle/fluid/tests/unittests/test_log_softmax.py b/python/paddle/fluid/tests/unittests/test_log_softmax.py index c37252a499fc10acf38219f0c43ebf9e519d66c3..e6377ed57456e6e5b5db531234462bbdc7b7383d 100644 --- a/python/paddle/fluid/tests/unittests/test_log_softmax.py +++ b/python/paddle/fluid/tests/unittests/test_log_softmax.py @@ -102,6 +102,29 @@ class TestLogSoftmaxAxis(TestLogSoftmaxOp): self.axis = 1 +class TestLogSoftmaxFP16OP(TestLogSoftmaxOp): + def set_attrs(self): + self.dtype = np.float16 + + def test_check_output(self): + self.check_output(atol=1e-3) + + def test_check_grad(self): + self.check_grad(['X'], ['Out'], max_relative_error=1e-2) + + +class TestLogSoftmaxShapeFP16OP(TestLogSoftmaxFP16OP): + def set_attrs(self): + self.dtype = np.float16 + self.shape = [12, 10] + + +class TestLogSoftmaxAxisFP16OP(TestLogSoftmaxFP16OP): + def set_attrs(self): + self.dtype = np.float16 + self.axis = 1 + + @unittest.skipIf( not core.is_compiled_with_cuda(), "core is not compiled with CUDA" )