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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. // Copyright 2019 Tencent
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. #include "testutil.h"
  4. static int test_elu(const ncnn::Mat& a)
  5. {
  6. ncnn::ParamDict pd;
  7. float alpha = RandomFloat(0.001f, 1000.f);
  8. pd.set(0, alpha); //alpha
  9. std::vector<ncnn::Mat> weights(0);
  10. int ret = test_layer("ELU", pd, weights, a);
  11. if (ret != 0)
  12. {
  13. fprintf(stderr, "test_elu failed a.dims=%d a=(%d %d %d %d) alpha=%f\n", a.dims, a.w, a.h, a.d, a.c, alpha);
  14. }
  15. return ret;
  16. }
  17. static int test_elu_0()
  18. {
  19. return 0
  20. || test_elu(RandomMat(7, 6, 5, 32))
  21. || test_elu(RandomMat(5, 6, 7, 24))
  22. || test_elu(RandomMat(7, 8, 9, 12))
  23. || test_elu(RandomMat(3, 4, 5, 13));
  24. }
  25. static int test_elu_1()
  26. {
  27. return 0
  28. || test_elu(RandomMat(4, 7, 32))
  29. || test_elu(RandomMat(5, 7, 24))
  30. || test_elu(RandomMat(7, 9, 12))
  31. || test_elu(RandomMat(3, 5, 13));
  32. }
  33. static int test_elu_2()
  34. {
  35. return 0
  36. || test_elu(RandomMat(13, 32))
  37. || test_elu(RandomMat(15, 24))
  38. || test_elu(RandomMat(17, 12))
  39. || test_elu(RandomMat(19, 15));
  40. }
  41. static int test_elu_3()
  42. {
  43. return 0
  44. || test_elu(RandomMat(128))
  45. || test_elu(RandomMat(124))
  46. || test_elu(RandomMat(127))
  47. || test_elu(RandomMat(120));
  48. }
  49. int main()
  50. {
  51. SRAND(7767517);
  52. return 0
  53. || test_elu_0()
  54. || test_elu_1()
  55. || test_elu_2()
  56. || test_elu_3();
  57. }