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

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