From b83526112416a2baeee29fe556d219074da5eb5f Mon Sep 17 00:00:00 2001 From: zzk0 <30856589+zzk0@users.noreply.github.com> Date: Mon, 5 Jun 2023 10:25:37 +0800 Subject: [PATCH] [CINN] Enable check_cinn on some tests (#54261) * [CINN] Enable check_cinn * add CMakeLists.txt --- test/legacy_test/CMakeLists.txt | 8 +++++++- test/legacy_test/test_arg_min_max_op.py | 2 +- test/legacy_test/test_flip.py | 8 ++++---- test/legacy_test/test_reverse_op.py | 4 ++-- test/legacy_test/test_scatter_nd_op.py | 8 ++++---- test/legacy_test/test_strided_slice_op.py | 8 ++++---- test/legacy_test/test_triangular_solve_op.py | 4 ++-- 7 files changed, 24 insertions(+), 18 deletions(-) diff --git a/test/legacy_test/CMakeLists.txt b/test/legacy_test/CMakeLists.txt index 3e4984832ec..d666116b6ad 100644 --- a/test/legacy_test/CMakeLists.txt +++ b/test/legacy_test/CMakeLists.txt @@ -1189,7 +1189,13 @@ set(TEST_CINN_OPS test_tile_op test_roll_op test_sum_op - test_elementwise_min_op) + test_elementwise_min_op + test_arg_min_max_op + test_reverse_op + test_flip + test_triangular_solve_op + test_scatter_nd_op + test_strided_slice_op) foreach(TEST_CINN_OPS ${TEST_CINN_OPS}) if(WITH_CINN) diff --git a/test/legacy_test/test_arg_min_max_op.py b/test/legacy_test/test_arg_min_max_op.py index 769fd7eb5da..fba469a0e33 100644 --- a/test/legacy_test/test_arg_min_max_op.py +++ b/test/legacy_test/test_arg_min_max_op.py @@ -42,7 +42,7 @@ class BaseTestCase(OpTest): self.outputs = {'Out': np.argmax(self.x, axis=self.axis)} def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) class TestCase0(BaseTestCase): diff --git a/test/legacy_test/test_flip.py b/test/legacy_test/test_flip.py index a06ef10ca06..e899511b150 100644 --- a/test/legacy_test/test_flip.py +++ b/test/legacy_test/test_flip.py @@ -100,10 +100,10 @@ class TestFlipOp(OpTest): self.attrs = {"axis": self.axis} def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): - self.check_grad(["X"], "Out") + self.check_grad(["X"], "Out", check_cinn=True) def init_test_case(self): self.in_shape = (6, 4, 2, 3) @@ -167,12 +167,12 @@ def create_test_fp16_class(parent): if core.is_compiled_with_cuda(): place = core.CUDAPlace(0) if core.is_float16_supported(place): - self.check_output_with_place(place) + self.check_output_with_place(place, check_cinn=True) def test_check_grad(self): place = core.CUDAPlace(0) if core.is_float16_supported(place): - self.check_grad_with_place(place, ["X"], "Out") + self.check_grad_with_place(place, ["X"], "Out", check_cinn=True) cls_name = "{}_{}".format(parent.__name__, "FP16OP") TestFlipFP16.__name__ = cls_name diff --git a/test/legacy_test/test_reverse_op.py b/test/legacy_test/test_reverse_op.py index 2b19496d582..91e90db9546 100644 --- a/test/legacy_test/test_reverse_op.py +++ b/test/legacy_test/test_reverse_op.py @@ -37,10 +37,10 @@ class TestReverseOp(OpTest): self.outputs = {'Out': out} def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): - self.check_grad(['X'], 'Out') + self.check_grad(['X'], 'Out', check_cinn=True) class TestCase0(TestReverseOp): diff --git a/test/legacy_test/test_scatter_nd_op.py b/test/legacy_test/test_scatter_nd_op.py index 66799466c59..ee6a2423e0d 100644 --- a/test/legacy_test/test_scatter_nd_op.py +++ b/test/legacy_test/test_scatter_nd_op.py @@ -93,7 +93,7 @@ class TestScatterNdAddSimpleOp(OpTest): self.dtype = np.float64 def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): self.check_grad(['X', 'Updates'], 'Out', check_prim=True) @@ -169,7 +169,7 @@ class TestScatterNdAddWithEmptyIndex(OpTest): self.dtype = np.float64 def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): self.check_grad(['X', 'Updates'], 'Out', check_prim=True) @@ -248,7 +248,7 @@ class TestScatterNdAddWithHighRankSame(OpTest): self.dtype = np.float64 def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): self.check_grad(['X', 'Updates'], 'Out', check_prim=True) @@ -311,7 +311,7 @@ class TestScatterNdAddWithHighRankDiff(OpTest): self.outputs = {'Out': expect_np} def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): self.check_grad(['X', 'Updates'], 'Out', check_prim=True) diff --git a/test/legacy_test/test_strided_slice_op.py b/test/legacy_test/test_strided_slice_op.py index 30406668781..85d71e63a57 100644 --- a/test/legacy_test/test_strided_slice_op.py +++ b/test/legacy_test/test_strided_slice_op.py @@ -96,10 +96,10 @@ class TestStrideSliceOp(OpTest): } def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): - self.check_grad({'Input'}, 'Out') + self.check_grad({'Input'}, 'Out', check_cinn=True) def initTestCase(self): self.input = np.random.rand(100) @@ -1032,10 +1032,10 @@ class TestStrideSliceFP16Op(OpTest): } def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad(self): - self.check_grad({'Input'}, 'Out') + self.check_grad({'Input'}, 'Out', check_cinn=True) def initTestCase(self): self.input = np.random.rand(100) diff --git a/test/legacy_test/test_triangular_solve_op.py b/test/legacy_test/test_triangular_solve_op.py index 520f7baf258..23cb650b14b 100644 --- a/test/legacy_test/test_triangular_solve_op.py +++ b/test/legacy_test/test_triangular_solve_op.py @@ -64,10 +64,10 @@ class TestTriangularSolveOp(OpTest): self.outputs = {'Out': self.output} def test_check_output(self): - self.check_output() + self.check_output(check_cinn=True) def test_check_grad_normal(self): - self.check_grad(['X', 'Y'], 'Out') + self.check_grad(['X', 'Y'], 'Out', check_cinn=True) # 2D(broadcast) + 3D, test 'transpose' -- GitLab