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.7 kB

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