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

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

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台