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_cumulativesum.cpp 1.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. // Copyright 2023 Xiaomi Corp. (author: Fangjun Kuang)
  2. // SPDX-License-Identifier: BSD-3-Clause
  3. #include "testutil.h"
  4. static int test_cumulativesum(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("CumulativeSum", pd, weights, a);
  10. if (ret != 0)
  11. {
  12. fprintf(stderr, "test_cumulativesum 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_cumulativesum_1d()
  17. {
  18. return 0
  19. || test_cumulativesum(RandomMat(6), 0)
  20. || test_cumulativesum(RandomMat(10), 0)
  21. || test_cumulativesum(RandomMat(10), -1)
  22. || test_cumulativesum(RandomMat(10), -2)
  23. || test_cumulativesum(RandomMat(101), 0);
  24. }
  25. static int test_cumulativesum_2d()
  26. {
  27. return 0
  28. || test_cumulativesum(RandomMat(6, 8), 0)
  29. || test_cumulativesum(RandomMat(20, 103), 1)
  30. || test_cumulativesum(RandomMat(106, 50), -1)
  31. || test_cumulativesum(RandomMat(106, 50), -2);
  32. }
  33. static int test_cumulativesum_3d()
  34. {
  35. return 0
  36. || test_cumulativesum(RandomMat(10, 6, 8), 0)
  37. || test_cumulativesum(RandomMat(303, 20, 103), 1)
  38. || test_cumulativesum(RandomMat(106, 50, 99), 2)
  39. || test_cumulativesum(RandomMat(303, 200, 103), -1)
  40. || test_cumulativesum(RandomMat(303, 200, 103), -2)
  41. || test_cumulativesum(RandomMat(303, 200, 103), -2);
  42. }
  43. int main()
  44. {
  45. SRAND(7767517);
  46. return 0
  47. || test_cumulativesum_1d()
  48. || test_cumulativesum_2d()
  49. || test_cumulativesum_3d();
  50. }