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.

rotate.cpp 2.3 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  1. #include "test/common/rotate.h"
  2. #include "test/common/benchmarker.h"
  3. #include "test/common/checker.h"
  4. #include "test/armv7/fixture.h"
  5. namespace megdnn {
  6. namespace test {
  7. TEST_F(ARMV7, ROTATE) {
  8. using namespace rotate;
  9. std::vector<TestArg> args = get_args();
  10. Checker<Rotate> checker(handle());
  11. for (auto&& arg : args) {
  12. checker.set_param(arg.param)
  13. .set_dtype(0, arg.dtype)
  14. .set_dtype(1, arg.dtype)
  15. .execs({arg.src, {}});
  16. }
  17. }
  18. TEST_F(ARMV7, BENCHMARK_ROTATE) {
  19. using namespace rotate;
  20. using Param = param::Rotate;
  21. #define BENCHMARK_PARAM(benchmarker, dtype) \
  22. benchmarker.set_param(param); \
  23. benchmarker.set_dtype(0, dtype);
  24. auto run = [&](const TensorShapeArray& shapes, Param param) {
  25. auto handle_naive = create_cpu_handle(2);
  26. Benchmarker<Rotate> benchmarker(handle());
  27. Benchmarker<Rotate> benchmarker_naive(handle_naive.get());
  28. BENCHMARK_PARAM(benchmarker, dtype::Uint8());
  29. BENCHMARK_PARAM(benchmarker_naive, dtype::Uint8());
  30. for (auto&& shape : shapes) {
  31. printf("execute %s: current---naive\n", shape.to_string().c_str());
  32. benchmarker.execs({shape, {}});
  33. benchmarker_naive.execs({shape, {}});
  34. }
  35. BENCHMARK_PARAM(benchmarker, dtype::Int32());
  36. BENCHMARK_PARAM(benchmarker_naive, dtype::Int32());
  37. for (auto&& shape : shapes) {
  38. printf("execute %s: current---naive\n", shape.to_string().c_str());
  39. benchmarker.execs({shape, {}});
  40. benchmarker_naive.execs({shape, {}});
  41. }
  42. BENCHMARK_PARAM(benchmarker, dtype::Float32());
  43. BENCHMARK_PARAM(benchmarker_naive, dtype::Float32());
  44. for (auto&& shape : shapes) {
  45. printf("execute %s: current---naive\n", shape.to_string().c_str());
  46. benchmarker.execs({shape, {}});
  47. benchmarker_naive.execs({shape, {}});
  48. }
  49. };
  50. Param param;
  51. TensorShapeArray shapes = {
  52. {1, 100, 100, 1},
  53. {2, 100, 100, 3},
  54. };
  55. param.clockwise = true;
  56. run(shapes, param);
  57. param.clockwise = false;
  58. run(shapes, param);
  59. }
  60. } // namespace test
  61. } // namespace megdnn
  62. // vim: syntax=cpp.doxygen