From a00db1fcbfa9c0d20e0827500b6d17470410c975 Mon Sep 17 00:00:00 2001 From: co63oc Date: Thu, 11 May 2023 20:49:45 +0800 Subject: [PATCH] Add fill_constant_batch_size_like tests --- .../test_fill_constant_batch_size_like.py | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like.py b/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like.py index d97fe6465dbba..bd077c87984ac 100644 --- a/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like.py +++ b/python/paddle/fluid/tests/unittests/test_fill_constant_batch_size_like.py @@ -38,11 +38,12 @@ def fill_constant_batch_size_like( ) -class TestFillConstatnBatchSizeLike1(OpTest): +class TestFillConstantBatchSizeLike1(OpTest): # test basic def setUp(self): self.op_type = "fill_constant_batch_size_like" self.python_api = fill_constant_batch_size_like + self.init_dtype() self.init_data() input = np.zeros(self.shape) @@ -59,9 +60,11 @@ def setUp(self): 'force_cpu': self.force_cpu, } + def init_dtype(self): + self.dtype = np.float32 + def init_data(self): self.shape = [10, 10] - self.dtype = np.float32 self.value = 100 self.input_dim_idx = 0 self.output_dim_idx = 0 @@ -71,11 +74,16 @@ def test_check_output(self): self.check_output() +class TestFillConstantBatchSizeLikeFP16Op(TestFillConstantBatchSizeLike1): + def init_dtype(self): + self.dtype = np.float16 + + @unittest.skipIf( not core.is_compiled_with_cuda() or not core.supports_bfloat16(), "core is not compiled with CUDA or place do not support bfloat16", ) -class TestFillConstatnBatchSizeLikeBf16(OpTest): +class TestFillConstantBatchSizeLikeBF16Op(OpTest): # test bf16 def setUp(self): self.op_type = "fill_constant_batch_size_like"