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.

roi_copy.cpp 1.8 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /**
  2. * \file dnn/test/fallback/roi_copy.cpp
  3. * MegEngine is Licensed under the Apache License, Version 2.0 (the "License")
  4. *
  5. * Copyright (c) 2014-2020 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 <gtest/gtest.h>
  12. #include "megdnn.h"
  13. #include "megdnn/oprs.h"
  14. #include "test/common/tensor.h"
  15. #include "test/common/roi_copy.h"
  16. #include "test/common/checker.h"
  17. #include "test/common/benchmarker.h"
  18. #include "test/fallback/fixture.h"
  19. namespace megdnn {
  20. namespace test {
  21. TEST_F(FALLBACK, ROICOPY) {
  22. using namespace roi_copy;
  23. std::vector<TestArg> args = get_args();
  24. Checker<ROICopy> checker(handle());
  25. checker.set_dtype(0, dtype::Int32());
  26. checker.set_dtype(1, dtype::Int32());
  27. for (auto&& arg : args) {
  28. checker.set_param(arg.param).execs({arg.src, {}});
  29. }
  30. }
  31. TEST_F(FALLBACK, BENCHMARK_ROICOPY) {
  32. auto run = [&](const TensorShapeArray& shapes) {
  33. Benchmarker<ROICopy> benchmarker(handle());
  34. benchmarker.set_dtype(0, dtype::Int32());
  35. benchmarker.set_dtype(1, dtype::Int32());
  36. benchmarker.set_times(5);
  37. ROICopy::Param param;
  38. for (auto&& shape : shapes) {
  39. param.row_from = shape[1]/10;
  40. param.row_to = shape[1]/2;
  41. param.col_from = shape[2]/9;
  42. param.col_to = shape[2]/3 * 2;
  43. benchmarker.set_param(param).execs({shape, {}});
  44. }
  45. #undef BENCHMARK_ROICopy
  46. };
  47. TensorShapeArray shapes = {
  48. {3, 1021, 980, 1},
  49. {3, 1021, 980, 3}
  50. };
  51. run(shapes);
  52. }
  53. } // namespace test
  54. } // namespace megdnn
  55. // vim: syntax=cpp.doxygen

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