未验证 提交 14e0ce71 编写于 作者: C Charles-hit 提交者: GitHub

fix meshgird and expand_as test (#53951)

上级 69d3f4e3
...@@ -103,10 +103,7 @@ class TestExpandAsOpRank2(TestExpandAsBasic): ...@@ -103,10 +103,7 @@ class TestExpandAsOpRank2(TestExpandAsBasic):
or not core.is_bfloat16_supported(core.CUDAPlace(0)), or not core.is_bfloat16_supported(core.CUDAPlace(0)),
"core is not compiled with CUDA or not support the bfloat16", "core is not compiled with CUDA or not support the bfloat16",
) )
class TestExpandAsOpRank2BFP16OP(TestExpandAsOpRank2): class TestExpandAsOpRank2BFP16OP(TestExpandAsBasicBFP16OP):
def init_dtype(self):
self.dtype = np.uint16
def init_inputs_and_outputs(self): def init_inputs_and_outputs(self):
x = np.random.rand(10, 12).astype(np.float32) x = np.random.rand(10, 12).astype(np.float32)
target_tensor = np.random.rand(10, 12).astype(np.float32) target_tensor = np.random.rand(10, 12).astype(np.float32)
...@@ -119,17 +116,6 @@ class TestExpandAsOpRank2BFP16OP(TestExpandAsOpRank2): ...@@ -119,17 +116,6 @@ class TestExpandAsOpRank2BFP16OP(TestExpandAsOpRank2):
output = np.tile(x, bcast_dims) output = np.tile(x, bcast_dims)
self.outputs = {'Out': convert_float_to_uint16(output)} self.outputs = {'Out': convert_float_to_uint16(output)}
def if_enable_cinn(self):
self.enable_cinn = False
def test_check_output(self):
self.check_output_with_place(place=paddle.CUDAPlace(0))
def test_check_grad(self):
self.check_grad_with_place(
paddle.CUDAPlace(0), ['X'], 'Out', check_prim=True
)
class TestExpandAsOpRank3(TestExpandAsBasic): class TestExpandAsOpRank3(TestExpandAsBasic):
def init_inputs_and_outputs(self): def init_inputs_and_outputs(self):
...@@ -147,10 +133,7 @@ class TestExpandAsOpRank3(TestExpandAsBasic): ...@@ -147,10 +133,7 @@ class TestExpandAsOpRank3(TestExpandAsBasic):
or not core.is_bfloat16_supported(core.CUDAPlace(0)), or not core.is_bfloat16_supported(core.CUDAPlace(0)),
"core is not compiled with CUDA or not support the bfloat16", "core is not compiled with CUDA or not support the bfloat16",
) )
class TestExpandAsOpRank3BFP16OP(TestExpandAsOpRank3): class TestExpandAsOpRank3BFP16OP(TestExpandAsBasicBFP16OP):
def init_dtype(self):
self.dtype = np.uint16
def init_inputs_and_outputs(self): def init_inputs_and_outputs(self):
x = np.random.rand(2, 3, 20).astype(np.float32) x = np.random.rand(2, 3, 20).astype(np.float32)
target_tensor = np.random.rand(2, 3, 20).astype(np.float32) target_tensor = np.random.rand(2, 3, 20).astype(np.float32)
...@@ -163,17 +146,6 @@ class TestExpandAsOpRank3BFP16OP(TestExpandAsOpRank3): ...@@ -163,17 +146,6 @@ class TestExpandAsOpRank3BFP16OP(TestExpandAsOpRank3):
output = np.tile(x, bcast_dims) output = np.tile(x, bcast_dims)
self.outputs = {'Out': convert_float_to_uint16(output)} self.outputs = {'Out': convert_float_to_uint16(output)}
def if_enable_cinn(self):
self.enable_cinn = False
def test_check_output(self):
self.check_output_with_place(place=paddle.CUDAPlace(0))
def test_check_grad(self):
self.check_grad_with_place(
paddle.CUDAPlace(0), ['X'], 'Out', check_prim=True
)
class TestExpandAsOpRank4(TestExpandAsBasic): class TestExpandAsOpRank4(TestExpandAsBasic):
def init_inputs_and_outputs(self): def init_inputs_and_outputs(self):
...@@ -191,10 +163,7 @@ class TestExpandAsOpRank4(TestExpandAsBasic): ...@@ -191,10 +163,7 @@ class TestExpandAsOpRank4(TestExpandAsBasic):
or not core.is_bfloat16_supported(core.CUDAPlace(0)), or not core.is_bfloat16_supported(core.CUDAPlace(0)),
"core is not compiled with CUDA or not support the bfloat16", "core is not compiled with CUDA or not support the bfloat16",
) )
class TestExpandAsOpRank4BFP16OP(TestExpandAsOpRank3): class TestExpandAsOpRank4BFP16OP(TestExpandAsBasicBFP16OP):
def init_dtype(self):
self.dtype = np.uint16
def init_inputs_and_outputs(self): def init_inputs_and_outputs(self):
x = np.random.rand(1, 1, 7, 16).astype(np.float32) x = np.random.rand(1, 1, 7, 16).astype(np.float32)
target_tensor = np.random.rand(4, 6, 7, 16).astype(np.float32) target_tensor = np.random.rand(4, 6, 7, 16).astype(np.float32)
...@@ -207,17 +176,6 @@ class TestExpandAsOpRank4BFP16OP(TestExpandAsOpRank3): ...@@ -207,17 +176,6 @@ class TestExpandAsOpRank4BFP16OP(TestExpandAsOpRank3):
output = np.tile(x, bcast_dims) output = np.tile(x, bcast_dims)
self.outputs = {'Out': convert_float_to_uint16(output)} self.outputs = {'Out': convert_float_to_uint16(output)}
def if_enable_cinn(self):
self.enable_cinn = False
def test_check_output(self):
self.check_output_with_place(place=paddle.CUDAPlace(0))
def test_check_grad(self):
self.check_grad_with_place(
paddle.CUDAPlace(0), ['X'], 'Out', check_prim=True
)
class TestExpandAsOpRank5(TestExpandAsBasic): class TestExpandAsOpRank5(TestExpandAsBasic):
no_need_check_grad = True no_need_check_grad = True
......
...@@ -32,13 +32,13 @@ class TestMeshgridOp(OpTest): ...@@ -32,13 +32,13 @@ class TestMeshgridOp(OpTest):
self.prim_op_type = "comp" self.prim_op_type = "comp"
self.python_api = meshgrid_wrapper self.python_api = meshgrid_wrapper
self.public_python_api = meshgrid_wrapper self.public_python_api = meshgrid_wrapper
self.dtype = self.get_dtype() self.init_data_type()
self.init_inputs_and_outputs() self.init_inputs_and_outputs()
self.python_out_sig = ['out0', 'out1'] self.python_out_sig = ['out0', 'out1']
self.if_enable_cinn() self.if_enable_cinn()
def get_dtype(self): def init_data_type(self):
return "float64" self.dtype = np.float64
def test_check_output(self): def test_check_output(self):
self.check_output(check_prim=True) self.check_output(check_prim=True)
...@@ -80,8 +80,8 @@ class TestMeshgridOp2Fp16(TestMeshgridOp): ...@@ -80,8 +80,8 @@ class TestMeshgridOp2Fp16(TestMeshgridOp):
def get_x_shape(self): def get_x_shape(self):
return [100, 300] return [100, 300]
def get_dtype(self): def init_data_type(self):
return np.float16 self.dtype = np.float16
@unittest.skipIf( @unittest.skipIf(
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册