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_shrink.cpp 1.5 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. // Copyright 2021 Tencent
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. #include "testutil.h"
  4. static int test_shrink(const ncnn::Mat& a, float lambd, float bias)
  5. {
  6. ncnn::ParamDict pd;
  7. pd.set(0, bias);
  8. pd.set(1, lambd);
  9. std::vector<ncnn::Mat> weights(0);
  10. int ret = test_layer("Shrink", pd, weights, a);
  11. if (ret != 0)
  12. {
  13. fprintf(stderr, "test_shrink failed a.dims=%d a=(%d %d %d %d)\n", a.dims, a.w, a.h, a.d, a.c);
  14. }
  15. return ret;
  16. }
  17. static int test_shrink_0()
  18. {
  19. return 0
  20. || test_shrink(RandomMat(12, 24, 8, 3), 0.5f, 5.0f)
  21. || test_shrink(RandomMat(9, 7, 16, 4), 1.0f, 0.3f)
  22. || test_shrink(RandomMat(6, 9, 4, 3), 4.5, 6.1);
  23. }
  24. static int test_shrink_1()
  25. {
  26. return 0
  27. || test_shrink(RandomMat(12, 6, 24), 0.5f, 5.0f)
  28. || test_shrink(RandomMat(7, 8, 24), 1.0f, 0.3f)
  29. || test_shrink(RandomMat(3, 4, 5), 4.5, 6.1);
  30. }
  31. static int test_shrink_2()
  32. {
  33. return 0
  34. || test_shrink(RandomMat(5, 7), 3.4f, 0.3f)
  35. || test_shrink(RandomMat(7, 9), 3.1f, 4.0f)
  36. || test_shrink(RandomMat(3, 5), 2.0f, 4.0f);
  37. }
  38. static int test_shrink_3()
  39. {
  40. return 0
  41. || test_shrink(RandomMat(25), 3.4f, 0.3f)
  42. || test_shrink(RandomMat(63), 3.1f, 4.0f)
  43. || test_shrink(RandomMat(1024), 2.0f, 4.0f);
  44. }
  45. int main()
  46. {
  47. SRAND(7767517);
  48. return 0
  49. || test_shrink_0()
  50. || test_shrink_1()
  51. || test_shrink_2()
  52. || test_shrink_3();
  53. }