You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_pixelshuffle.cpp 1.7 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. // Copyright 2020 Tencent
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. #include "testutil.h"
  4. static int test_pixelshuffle(const ncnn::Mat& a, int upscale_factor, int mode)
  5. {
  6. ncnn::ParamDict pd;
  7. pd.set(0, upscale_factor);
  8. pd.set(1, mode);
  9. std::vector<ncnn::Mat> weights(0);
  10. int ret = test_layer("PixelShuffle", pd, weights, a);
  11. if (ret != 0)
  12. {
  13. fprintf(stderr, "test_pixelshuffle failed a.dims=%d a=(%d %d %d) upscale_factor=%d mode=%d\n", a.dims, a.w, a.h, a.c, upscale_factor, mode);
  14. }
  15. return ret;
  16. }
  17. static int test_pixelshuffle_0()
  18. {
  19. return 0
  20. || test_pixelshuffle(RandomMat(7, 7, 1), 1, 0)
  21. || test_pixelshuffle(RandomMat(7, 7, 8), 2, 0)
  22. || test_pixelshuffle(RandomMat(7, 7, 12), 2, 0)
  23. || test_pixelshuffle(RandomMat(7, 7, 64), 4, 0)
  24. || test_pixelshuffle(RandomMat(7, 7, 32), 2, 0)
  25. || test_pixelshuffle(RandomMat(7, 7, 48), 2, 0)
  26. || test_pixelshuffle(RandomMat(7, 7, 36), 3, 0)
  27. || test_pixelshuffle(RandomMat(7, 7, 72), 3, 0)
  28. || test_pixelshuffle(RandomMat(7, 7, 90), 3, 0);
  29. }
  30. static int test_pixelshuffle_1()
  31. {
  32. return 0
  33. || test_pixelshuffle(RandomMat(7, 7, 1), 1, 1)
  34. || test_pixelshuffle(RandomMat(7, 7, 8), 2, 1)
  35. || test_pixelshuffle(RandomMat(7, 7, 12), 2, 1)
  36. || test_pixelshuffle(RandomMat(7, 7, 64), 4, 1)
  37. || test_pixelshuffle(RandomMat(7, 7, 32), 2, 1)
  38. || test_pixelshuffle(RandomMat(7, 7, 48), 2, 1)
  39. || test_pixelshuffle(RandomMat(7, 7, 36), 3, 1)
  40. || test_pixelshuffle(RandomMat(7, 7, 90), 3, 1);
  41. }
  42. int main()
  43. {
  44. SRAND(7767517);
  45. return test_pixelshuffle_0() || test_pixelshuffle_1();
  46. }