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_glu.cpp 1.4 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. // Copyright 2022 Xiaomi Corp. (author: Fangjun Kuang)
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. #include "testutil.h"
  4. static int test_glu(const ncnn::Mat& a, int axis)
  5. {
  6. ncnn::ParamDict pd;
  7. pd.set(0, axis);
  8. std::vector<ncnn::Mat> weights(0);
  9. int ret = test_layer("GLU", pd, weights, a);
  10. if (ret != 0)
  11. {
  12. fprintf(stderr, "test_glu failed a.dims=%d a=(%d %d %d) axis=%d\n", a.dims, a.w, a.h, a.c, axis);
  13. }
  14. return ret;
  15. }
  16. static int test_glu_0()
  17. {
  18. return 0
  19. || test_glu(RandomMat(6, 7, 24), 0)
  20. || test_glu(RandomMat(6, 8, 24), 1)
  21. || test_glu(RandomMat(6, 8, 24), 2)
  22. || test_glu(RandomMat(36, 7, 22), 0)
  23. || test_glu(RandomMat(5, 256, 23), -2)
  24. || test_glu(RandomMat(129, 9, 60), 2)
  25. || test_glu(RandomMat(129, 9, 30), -1);
  26. }
  27. static int test_glu_1()
  28. {
  29. return 0
  30. || test_glu(RandomMat(10, 24), 0)
  31. || test_glu(RandomMat(7, 24), 1)
  32. || test_glu(RandomMat(128, 22), 0)
  33. || test_glu(RandomMat(128, 256), 1);
  34. }
  35. static int test_glu_2()
  36. {
  37. return 0
  38. || test_glu(RandomMat(10), 0)
  39. || test_glu(RandomMat(20), 0)
  40. || test_glu(RandomMat(128), 0);
  41. }
  42. int main()
  43. {
  44. SRAND(7767517);
  45. return 0
  46. || test_glu_0()
  47. || test_glu_1()
  48. || test_glu_2();
  49. }