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.9 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright (c) 2022 Xiaomi Corp. (author: Fangjun Kuang)
  2. //
  3. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  4. // in compliance with the License. You may obtain a copy of the License at
  5. //
  6. // https://opensource.org/licenses/BSD-3-Clause
  7. //
  8. // Unless required by applicable law or agreed to in writing, software distributed
  9. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  10. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  11. // specific language governing permissions and limitations under the License.
  12. #include "testutil.h"
  13. static int test_glu(const ncnn::Mat& a, int axis)
  14. {
  15. ncnn::ParamDict pd;
  16. pd.set(0, axis);
  17. std::vector<ncnn::Mat> weights(0);
  18. int ret = test_layer("GLU", pd, weights, a);
  19. if (ret != 0)
  20. {
  21. fprintf(stderr, "test_glu failed a.dims=%d a=(%d %d %d) axis=%d\n", a.dims, a.w, a.h, a.c, axis);
  22. }
  23. return ret;
  24. }
  25. static int test_glu_0()
  26. {
  27. return 0
  28. || test_glu(RandomMat(6, 7, 24), 0)
  29. || test_glu(RandomMat(6, 8, 24), 1)
  30. || test_glu(RandomMat(6, 8, 24), 2)
  31. || test_glu(RandomMat(36, 7, 22), 0)
  32. || test_glu(RandomMat(5, 256, 23), -2)
  33. || test_glu(RandomMat(129, 9, 60), 2)
  34. || test_glu(RandomMat(129, 9, 30), -1);
  35. }
  36. static int test_glu_1()
  37. {
  38. return 0
  39. || test_glu(RandomMat(10, 24), 0)
  40. || test_glu(RandomMat(7, 24), 1)
  41. || test_glu(RandomMat(128, 22), 0)
  42. || test_glu(RandomMat(128, 256), 1);
  43. }
  44. static int test_glu_2()
  45. {
  46. return 0
  47. || test_glu(RandomMat(10), 0)
  48. || test_glu(RandomMat(20), 0)
  49. || test_glu(RandomMat(128), 0);
  50. }
  51. int main()
  52. {
  53. SRAND(7767517);
  54. return 0
  55. || test_glu_0()
  56. || test_glu_1()
  57. || test_glu_2();
  58. }