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_tanh.cpp 1.3 kB

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