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.

cumsum.cpp 2.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * \file dnn/test/cuda/cumsum.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2021 Megvii Inc. All rights reserved.
  6. *
  7. * Unless required by applicable law or agreed to in writing,
  8. * software distributed under the License is distributed on an
  9. * "AS IS" BASIS, WITHOUT ARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. */
  11. #include "test/cuda/fixture.h"
  12. #include "megdnn/oprs.h"
  13. #include "test/common/checker.h"
  14. namespace megdnn {
  15. namespace test {
  16. TEST_F(CUDA, CUMSUM) {
  17. Checker<Cumsum> checker(handle_cuda());
  18. struct TestArg {
  19. param::Cumsum param;
  20. TensorShape shape;
  21. TestArg(param::Cumsum param, TensorShape shape) : param(param), shape(shape) {}
  22. };
  23. std::vector<TestArg> args, args_int32;
  24. for (auto shape :
  25. TensorShapeArray{{10000}, {33000, 33}, {100, 100, 100}, {30, 30, 30, 30}}) {
  26. for (size_t axis = 0; axis < shape.ndim; ++axis) {
  27. args.emplace_back(param::Cumsum(axis, true, true), shape);
  28. args.emplace_back(param::Cumsum(axis, true, false), shape);
  29. args.emplace_back(param::Cumsum(axis, false, true), shape);
  30. args.emplace_back(param::Cumsum(axis, false, false), shape);
  31. }
  32. }
  33. for (auto shape : TensorShapeArray{{1}, {10}, {100}, {1000}, {10000}, {100000}}) {
  34. args.emplace_back(param::Cumsum(0, true, true), shape);
  35. args.emplace_back(param::Cumsum(0, true, false), shape);
  36. args.emplace_back(param::Cumsum(0, false, true), shape);
  37. args.emplace_back(param::Cumsum(0, false, false), shape);
  38. }
  39. for (auto shape : TensorShapeArray{
  40. {1},
  41. {10},
  42. {100},
  43. {1000},
  44. {10000},
  45. {100000},
  46. {1000000},
  47. {1050000},
  48. {2100000}}) {
  49. args_int32.emplace_back(param::Cumsum(0, true, true), shape);
  50. args_int32.emplace_back(param::Cumsum(0, true, false), shape);
  51. args_int32.emplace_back(param::Cumsum(0, false, true), shape);
  52. args_int32.emplace_back(param::Cumsum(0, false, false), shape);
  53. }
  54. for (auto arg : args) {
  55. checker.set_param(arg.param);
  56. checker.set_epsilon(1e-2);
  57. checker.set_dtype(0, dtype::Float32()).execs({{arg.shape}, {}});
  58. checker.set_dtype(0, dtype::Int16()).execs({{arg.shape}, {}});
  59. checker.set_dtype(0, dtype::Int32()).execs({{arg.shape}, {}});
  60. }
  61. for (auto arg : args_int32) {
  62. checker.set_param(arg.param);
  63. checker.set_epsilon(1e-2);
  64. checker.set_dtype(0, dtype::Int32()).execs({{arg.shape}, {}});
  65. }
  66. }
  67. } // namespace test
  68. } // namespace megdnn
  69. // vim: syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}