未验证 提交 bed54a70 编写于 作者: zhenhailiu's avatar zhenhailiu 提交者: GitHub

[AMP OP&Test] element_wise_add_fp16_test (#52240)

上级 d2cdc7e3
......@@ -143,15 +143,29 @@ class TestFP16ElementwiseAddOp(TestElementwiseAddOp):
def test_check_output(self):
# TODO(wangzhongpu): support mkldnn op in dygraph mode
if core.is_compiled_with_cuda():
place = core.CUDAPlace(0)
if core.is_float16_supported(place):
self.check_output_with_place(
place,
atol=1e-3,
check_dygraph=self.check_dygraph(),
check_prim=self.check_prim,
)
place = core.CUDAPlace(0)
self.check_output_with_place(
place,
atol=1e-3,
check_dygraph=self.check_dygraph(),
check_prim=self.check_prim,
)
def test_check_grad_normal(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(place, ['X', 'Y'], 'Out', check_prim=True)
def test_check_grad_ingore_x(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['Y'], 'Out', no_grad_set=set("X"), check_prim=True
)
def test_check_grad_ingore_y(self):
place = core.CUDAPlace(0)
self.check_grad_with_place(
place, ['X'], 'Out', no_grad_set=set('Y'), check_prim=True
)
@unittest.skipIf(
......@@ -487,11 +501,14 @@ class TestElementwiseAddOp_rowwise_add_1(TestElementwiseAddOp):
self.enable_cinn = False
@skip_check_grad_ci(
reason="[skip shape check] Use y_shape(1) to test broadcast."
)
class TestFP16ElementwiseAddOp_rowwise_add_1(TestFP16ElementwiseAddOp):
def init_input_output(self):
self.x = np.random.rand(100, 1).astype(self.dtype)
self.y = np.random.rand(1).astype(self.dtype)
self.out = self.x + self.y.reshape(1, 1)
self.out = self.x + self.y
class TestElementwiseAddOp_channelwise_add(TestElementwiseAddOp):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册