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.

warp_afffine.cpp 2.5 kB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. #include "test/naive/fixture.h"
  2. #include "megdnn/oprs/cv.h"
  3. #include "test/common/checker.h"
  4. #include "test/common/warp_affine.h"
  5. using namespace megdnn;
  6. using namespace test;
  7. TEST_F(NAIVE, WARP_AFFINE) {
  8. Checker<WarpAffine> checker(handle(), false);
  9. WarpAffine::Param param;
  10. param.border_mode = WarpAffine::Param::BorderMode::BORDER_REFLECT;
  11. param.imode = WarpAffine::Param::InterpolationMode::LINEAR;
  12. param.format = WarpAffine::Param::Format::NCHW;
  13. checker.set_param(param).exect(
  14. Testcase{
  15. TensorValue(
  16. {1, 1, 3, 3}, dtype::Uint8{},
  17. {131, 255, 180, 245, 8, 0, 10, 3, 178}),
  18. TensorValue(
  19. {1, 2, 3}, dtype::Float32{},
  20. {1.2f, 1.2f, 0.6f, -1.05f, -2.0f, -0.7f}),
  21. {}},
  22. Testcase{
  23. {},
  24. {},
  25. TensorValue({1, 1, 2, 2}, dtype::Uint8{}, {205, 50, 101, 178})});
  26. checker.set_param(param).exect(
  27. Testcase{
  28. TensorValue(
  29. {1, 1, 3, 3},
  30. dtype::Quantized8Asymm{1.4f, static_cast<uint8_t>(127)},
  31. {131, 255, 180, 245, 8, 0, 10, 3, 178}),
  32. TensorValue(
  33. {1, 2, 3}, dtype::Float32{},
  34. {1.2f, 1.2f, 0.6f, -1.05f, -2.0f, -0.7f}),
  35. {}},
  36. Testcase{
  37. {},
  38. {},
  39. TensorValue(
  40. {1, 1, 2, 2},
  41. dtype::Quantized8Asymm{1.4f, static_cast<uint8_t>(127)},
  42. {205, 50, 101, 178})});
  43. }
  44. TEST_F(NAIVE_MULTI_THREADS, WARP_AFFINE_CV) {
  45. using namespace warp_affine;
  46. std::vector<TestArg> args = get_cv_args();
  47. Checker<WarpAffine> checker(handle());
  48. for (auto&& arg : args) {
  49. checker.set_param(arg.param)
  50. .set_dtype(0, dtype::Uint8())
  51. .set_dtype(1, dtype::Float32())
  52. .set_dtype(2, dtype::Uint8())
  53. .execs({arg.src, arg.trans, arg.dst});
  54. }
  55. for (auto&& arg : args) {
  56. checker.set_param(arg.param)
  57. .set_dtype(0, dtype::Float32())
  58. .set_dtype(1, dtype::Float32())
  59. .set_dtype(2, dtype::Float32())
  60. .execs({arg.src, arg.trans, arg.dst});
  61. }
  62. }
  63. // vim: syntax=cpp.doxygen