Skip to content

Commit

Permalink
ctest 8
Browse files Browse the repository at this point in the history
  • Loading branch information
Baiyuetribe committed Jan 13, 2025
1 parent 5ba56f3 commit ad65148
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 39 deletions.
42 changes: 5 additions & 37 deletions tests/test_flip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
8 changes: 6 additions & 2 deletions tools/pnnx/tests/ncnn/test_torch_flip.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def forward(self, x, y, z, d):
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])
Expand All @@ -79,8 +80,9 @@ def forward(self, x, y, z, d):
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,
Expand All @@ -93,6 +95,7 @@ def forward(self, x, y, z, d):
z3,
z4,
z5,
z6,
d0,
d1,
d2,
Expand All @@ -107,6 +110,7 @@ def forward(self, x, y, z, d):
d11,
d12,
d13,
d14,
)


Expand Down

0 comments on commit ad65148

Please sign in to comment.