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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. #if MEGDNN_WITH_BENCHMARK
  32. TEST_F(FALLBACK, BENCHMARK_ROICOPY) {
  33. auto run = [&](const TensorShapeArray& shapes) {
  34. Benchmarker<ROICopy> benchmarker(handle());
  35. benchmarker.set_dtype(0, dtype::Int32());
  36. benchmarker.set_dtype(1, dtype::Int32());
  37. benchmarker.set_times(5);
  38. ROICopy::Param param;
  39. for (auto&& shape : shapes) {
  40. param.row_from = shape[1]/10;
  41. param.row_to = shape[1]/2;
  42. param.col_from = shape[2]/9;
  43. param.col_to = shape[2]/3 * 2;
  44. benchmarker.set_param(param).execs({shape, {}});
  45. }
  46. #undef BENCHMARK_ROICopy
  47. };
  48. TensorShapeArray shapes = {
  49. {3, 1021, 980, 1},
  50. {3, 1021, 980, 3}
  51. };
  52. run(shapes);
  53. }
  54. #endif
  55. } // namespace test
  56. } // namespace megdnn
  57. // vim: syntax=cpp.doxygen

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