From 96983a7d69a8b644756e692f70f359ed2538c9f8 Mon Sep 17 00:00:00 2001 From: cyberslack_lee Date: Thu, 14 Sep 2023 14:26:28 +0800 Subject: [PATCH] [NewIR] No.13 Migrate paddle.multiply into pir (#57175) --- python/paddle/tensor/math.py | 2 +- test/legacy_test/test_elementwise_mul_op.py | 18 +++++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/python/paddle/tensor/math.py b/python/paddle/tensor/math.py index 76b8b781748c26..bb2c7cc4898948 100644 --- a/python/paddle/tensor/math.py +++ b/python/paddle/tensor/math.py @@ -1081,7 +1081,7 @@ def multiply(x, y, name=None): [2, 4, 6]]]) """ - if in_dynamic_mode(): + if in_dynamic_or_pir_mode(): return _C_ops.multiply(x, y) else: if x.dtype != y.dtype: diff --git a/test/legacy_test/test_elementwise_mul_op.py b/test/legacy_test/test_elementwise_mul_op.py index b03a9d0d2980fc..86f4e764916e07 100644 --- a/test/legacy_test/test_elementwise_mul_op.py +++ b/test/legacy_test/test_elementwise_mul_op.py @@ -47,7 +47,10 @@ def setUp(self): def test_check_output(self): # TODO(wangzhongpu): support mkldnn op in dygraph mode - self.check_output(check_dygraph=(not self.use_mkldnn)) + self.check_output( + check_dygraph=(not self.use_mkldnn), + check_new_ir=(not self.use_mkldnn), + ) def test_check_grad_normal(self): # TODO(wangzhongpu): support mkldnn op in dygraph mode @@ -56,6 +59,7 @@ def test_check_grad_normal(self): 'Out', check_dygraph=(not self.use_mkldnn), check_prim=True, + check_new_ir=(not self.use_mkldnn), ) def test_check_grad_ingore_x(self): @@ -66,6 +70,7 @@ def test_check_grad_ingore_x(self): no_grad_set=set("X"), check_dygraph=(not self.use_mkldnn), check_prim=True, + check_new_ir=(not self.use_mkldnn), ) def test_check_grad_ingore_y(self): @@ -76,6 +81,7 @@ def test_check_grad_ingore_y(self): no_grad_set=set('Y'), check_dygraph=(not self.use_mkldnn), check_prim=True, + check_new_ir=(not self.use_mkldnn), ) def init_input_output(self): @@ -193,7 +199,7 @@ def test_check_output(self): self.check_output() def test_check_grad_normal(self): - self.check_grad(['X', 'Y'], 'Out', check_prim=True) + self.check_grad(['X', 'Y'], 'Out', check_prim=True, check_new_ir=True) def test_check_grad_ingore_x(self): self.check_grad( @@ -201,6 +207,7 @@ def test_check_grad_ingore_x(self): 'Out', no_grad_set=set("X"), check_prim=True, + check_new_ir=True, ) def test_check_grad_ingore_y(self): @@ -209,6 +216,7 @@ def test_check_grad_ingore_y(self): 'Out', no_grad_set=set('Y'), check_prim=True, + check_new_ir=True, ) def if_enable_cinn(self): @@ -264,7 +272,8 @@ def setUp(self): def test_check_output(self): self.check_output( - check_dygraph=self.check_dygraph, check_prim=self.check_prim + check_dygraph=self.check_dygraph, + check_prim=self.check_prim, ) def test_check_grad_normal(self): @@ -418,6 +427,7 @@ def test_check_grad_normal(self): 'Out', check_dygraph=(not self.use_mkldnn), check_prim=True, + check_new_ir=(not self.use_mkldnn), ) def test_check_grad_ingore_x(self): @@ -428,6 +438,7 @@ def test_check_grad_ingore_x(self): no_grad_set=set("X"), check_dygraph=(not self.use_mkldnn), check_prim=True, + check_new_ir=(not self.use_mkldnn), ) def test_check_grad_ingore_y(self): @@ -438,6 +449,7 @@ def test_check_grad_ingore_y(self): no_grad_set=set('Y'), check_dygraph=(not self.use_mkldnn), check_prim=True, + check_new_ir=(not self.use_mkldnn), )