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

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