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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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-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 <gtest/gtest.h>
  12. #include "megdnn.h"
  13. #include "megdnn/oprs.h"
  14. #include "test/common/benchmarker.h"
  15. #include "test/common/checker.h"
  16. #include "test/common/roi_copy.h"
  17. #include "test/common/task_record_check.h"
  18. #include "test/common/tensor.h"
  19. #include "test/fallback/fixture.h"
  20. namespace megdnn {
  21. namespace test {
  22. TEST_F(FALLBACK, ROICOPY) {
  23. using namespace roi_copy;
  24. std::vector<TestArg> args = get_args();
  25. Checker<ROICopy> checker(handle());
  26. checker.set_dtype(0, dtype::Int32());
  27. checker.set_dtype(1, dtype::Int32());
  28. for (auto&& arg : args) {
  29. checker.set_param(arg.param).execs({arg.src, {}});
  30. }
  31. }
  32. TEST_F(FALLBACK, ROICOPY_RECORD) {
  33. using namespace roi_copy;
  34. std::vector<TestArg> args = get_args();
  35. TaskRecordChecker<ROICopy> checker(1);
  36. checker.set_dtype(0, dtype::Int32());
  37. checker.set_dtype(1, dtype::Int32());
  38. for (auto&& arg : args) {
  39. checker.set_param(arg.param).execs({arg.src, {}});
  40. }
  41. }
  42. #if MEGDNN_WITH_BENCHMARK
  43. TEST_F(FALLBACK, BENCHMARK_ROICOPY) {
  44. auto run = [&](const TensorShapeArray& shapes) {
  45. Benchmarker<ROICopy> benchmarker(handle());
  46. benchmarker.set_dtype(0, dtype::Int32());
  47. benchmarker.set_dtype(1, dtype::Int32());
  48. benchmarker.set_times(5);
  49. ROICopy::Param param;
  50. for (auto&& shape : shapes) {
  51. param.row_from = shape[1] / 10;
  52. param.row_to = shape[1] / 2;
  53. param.col_from = shape[2] / 9;
  54. param.col_to = shape[2] / 3 * 2;
  55. benchmarker.set_param(param).execs({shape, {}});
  56. }
  57. #undef BENCHMARK_ROICopy
  58. };
  59. TensorShapeArray shapes = {{3, 1021, 980, 1}, {3, 1021, 980, 3}};
  60. run(shapes);
  61. }
  62. #endif
  63. } // namespace test
  64. } // namespace megdnn
  65. // vim: syntax=cpp.doxygen