From ad65148c298fb4196d7a7088de166ef2b8a01211 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=B0=E9=98=85?= <43716063+Baiyuetribe@users.noreply.github.com> Date: Tue, 14 Jan 2025 00:12:16 +0800 Subject: [PATCH] ctest 8 --- tests/test_flip.cpp | 42 +++--------------------- tools/pnnx/tests/ncnn/test_torch_flip.py | 8 +++-- 2 files changed, 11 insertions(+), 39 deletions(-) diff --git a/tests/test_flip.cpp b/tests/test_flip.cpp index 1dc0233c8..7ebf787a4 100644 --- a/tests/test_flip.cpp +++ b/tests/test_flip.cpp @@ -124,41 +124,9 @@ static int test_flip_3() int main() { SRAND(7767517); - // return 0 - // || test_flip_0() - // || test_flip_1() - // || test_flip_2() - // || test_flip_3(); - - // debug 测出所有异常 - test_flip(RandomMat(2, 3, 4, 5), IntArrayMat(0)); - test_flip(RandomMat(3, 2, 4, 5), IntArrayMat(1)); - test_flip(RandomMat(4, 3, 2, 5), IntArrayMat(2)); - test_flip(RandomMat(2, 3, 1, 5), IntArrayMat(3)); - test_flip(RandomMat(6, 3, 4, 5), IntArrayMat(0, 1)); - test_flip(RandomMat(2, 3, 1, 6), IntArrayMat(0, 2)); - test_flip(RandomMat(5, 1, 2, 5), IntArrayMat(0, 3)); - test_flip(RandomMat(5, 2, 1, 5), IntArrayMat(1, 2)); - test_flip(RandomMat(4, 5, 2, 3), IntArrayMat(1, 3)); - test_flip(RandomMat(2, 6, 4, 5), IntArrayMat(2, 3)); - test_flip(RandomMat(6, 1, 4, 5), IntArrayMat(0, 1, 2)); - test_flip(RandomMat(5, 2, 1, 5), IntArrayMat(0, 1, 3)); - test_flip(RandomMat(4, 3, 3, 5), IntArrayMat(0, 2, 3)); - test_flip(RandomMat(4, 3, 4, 5), IntArrayMat(1, 2, 3)); - test_flip(RandomMat(6, 3, 3, 2), IntArrayMat(0, 1, 2, 3)); - - test_flip(RandomMat(2, 3, 5), IntArrayMat(0)); - test_flip(RandomMat(3, 3, 5), IntArrayMat(1)); - test_flip(RandomMat(4, 3, 5), IntArrayMat(2)); - test_flip(RandomMat(3, 1, 5), IntArrayMat(0, 1)); - test_flip(RandomMat(3, 2, 5), IntArrayMat(0, 2)); - test_flip(RandomMat(3, 3, 4), IntArrayMat(1, 2)); - test_flip(RandomMat(4, 3, 2), IntArrayMat(0, 1, 2)); - - test_flip(RandomMat(8, 2), IntArrayMat(-2)); - test_flip(RandomMat(16, 3), IntArrayMat(-1)); - test_flip(RandomMat(7, 2), IntArrayMat(-2, -1)); - - test_flip(RandomMat(18), IntArrayMat(-1)); - return -1; + return 0 + || test_flip_0() + || test_flip_1() + || test_flip_2() + || test_flip_3(); } \ No newline at end of file diff --git a/tools/pnnx/tests/ncnn/test_torch_flip.py b/tools/pnnx/tests/ncnn/test_torch_flip.py index 4c9702cc5..b07a8d297 100644 --- a/tools/pnnx/tests/ncnn/test_torch_flip.py +++ b/tools/pnnx/tests/ncnn/test_torch_flip.py @@ -66,6 +66,7 @@ class Model(nn.Module): z3 = torch.flip(z, [0, 1]) z4 = torch.flip(z, [0, 2]) z5 = torch.flip(z, [1, 2]) + z6 = torch.flip(z, [0, 1, 2]) # 4D d0 = torch.flip(d, [-1]) d1 = torch.flip(d, [-2]) @@ -79,8 +80,9 @@ class Model(nn.Module): d9 = torch.flip(d, [2, 3]) d10 = torch.flip(d, [0, 1, 2]) d11 = torch.flip(d, [0, 1, 3]) - d12 = torch.flip(d, [1, 2, 3]) - d13 = torch.flip(d, [0, 1, 2, 3]) + d12 = torch.flip(d, [0, 2, 3]) + d13 = torch.flip(d, [1, 2, 3]) + d14 = torch.flip(d, [0, 1, 2, 3]) return ( x0, @@ -93,6 +95,7 @@ class Model(nn.Module): z3, z4, z5, + z6, d0, d1, d2, @@ -107,6 +110,7 @@ class Model(nn.Module): d11, d12, d13, + d14, )