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

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

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