Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PIR]add all add , mul newir optest #57533

Merged
merged 3 commits into from
Sep 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 5 additions & 16 deletions test/legacy_test/test_elementwise_add_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def setUp(self):

def test_check_output(self):
place = core.CUDAPlace(0)
self.check_output_with_place(place)
self.check_output_with_place(place, check_new_ir=True)

def test_check_grad_normal(self):
place = core.CUDAPlace(0)
Expand Down Expand Up @@ -738,27 +738,16 @@ def init_input_output(self):
self.out = self.x + self.y

def test_check_output(self):
self.check_output()
self.check_output(check_new_ir=False)

def test_check_grad_normal(self):
self.check_grad(
['X', 'Y'],
'Out',
)
self.check_grad(['X', 'Y'], 'Out', check_new_ir=False)

def test_check_grad_ingore_x(self):
self.check_grad(
['Y'],
'Out',
no_grad_set=set("X"),
)
self.check_grad(['Y'], 'Out', no_grad_set=set("X"), check_new_ir=False)

def test_check_grad_ingore_y(self):
self.check_grad(
['X'],
'Out',
no_grad_set=set('Y'),
)
self.check_grad(['X'], 'Out', no_grad_set=set('Y'), check_new_ir=False)


class TestRealComplexElementwiseAddOp(TestComplexElementwiseAddOp):
Expand Down
42 changes: 12 additions & 30 deletions test/legacy_test/test_elementwise_mul_op.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,24 +128,13 @@ def if_enable_cinn(self):
self.enable_cinn = False

def test_check_grad_normal(self):
self.check_grad(
['X', 'Y'],
'Out',
)
self.check_grad(['X', 'Y'], 'Out', check_new_ir=False)

def test_check_grad_ingore_x(self):
self.check_grad(
['Y'],
'Out',
no_grad_set=set("X"),
)
self.check_grad(['Y'], 'Out', no_grad_set=set("X"), check_new_ir=False)

def test_check_grad_ingore_y(self):
self.check_grad(
['X'],
'Out',
no_grad_set=set('Y'),
)
self.check_grad(['X'], 'Out', no_grad_set=set('Y'), check_new_ir=False)


class TestElementwiseMulOp_ZeroDim1(ElementwiseMulOp):
Expand Down Expand Up @@ -196,7 +185,7 @@ def setUp(self):
self.if_enable_cinn()

def test_check_output(self):
self.check_output()
self.check_output(check_new_ir=True)

def test_check_grad_normal(self):
self.check_grad(['X', 'Y'], 'Out', check_prim=True, check_new_ir=True)
Expand Down Expand Up @@ -274,6 +263,7 @@ def test_check_output(self):
self.check_output(
check_dygraph=self.check_dygraph,
check_prim=self.check_prim,
check_new_ir=self.check_dygraph,
)

def test_check_grad_normal(self):
Expand All @@ -282,6 +272,7 @@ def test_check_grad_normal(self):
'Out',
check_dygraph=self.check_dygraph,
check_prim=self.check_prim,
check_new_ir=self.check_dygraph,
)

def test_check_grad_ingore_x(self):
Expand All @@ -291,6 +282,7 @@ def test_check_grad_ingore_x(self):
no_grad_set=set("X"),
check_dygraph=self.check_dygraph,
check_prim=self.check_prim,
check_new_ir=self.check_dygraph,
)

def test_check_grad_ingore_y(self):
Expand All @@ -300,6 +292,7 @@ def test_check_grad_ingore_y(self):
no_grad_set=set('Y'),
check_dygraph=self.check_dygraph,
check_prim=self.check_prim,
check_new_ir=self.check_dygraph,
)

def init_input_attr_output(self):
Expand Down Expand Up @@ -527,27 +520,16 @@ def init_input_output(self):
self.out = self.x * self.y

def test_check_output(self):
self.check_output()
self.check_output(check_new_ir=False)

def test_check_grad_normal(self):
self.check_grad(
['X', 'Y'],
'Out',
)
self.check_grad(['X', 'Y'], 'Out', check_new_ir=False)

def test_check_grad_ingore_x(self):
self.check_grad(
['Y'],
'Out',
no_grad_set=set("X"),
)
self.check_grad(['Y'], 'Out', no_grad_set=set("X"), check_new_ir=False)

def test_check_grad_ingore_y(self):
self.check_grad(
['X'],
'Out',
no_grad_set=set('Y'),
)
self.check_grad(['X'], 'Out', no_grad_set=set('Y'), check_new_ir=False)


class TestRealComplexElementwiseMulOp(TestComplexElementwiseMulOp):
Expand Down