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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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-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 "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{
  25. TensorValue(
  26. {1, 1, 3, 3}, dtype::Uint8{},
  27. {131, 255, 180, 245, 8, 0, 10, 3, 178}),
  28. TensorValue(
  29. {1, 2, 3}, dtype::Float32{},
  30. {1.2f, 1.2f, 0.6f, -1.05f, -2.0f, -0.7f}),
  31. {}},
  32. Testcase{
  33. {},
  34. {},
  35. TensorValue({1, 1, 2, 2}, dtype::Uint8{}, {205, 50, 101, 178})});
  36. checker.set_param(param).exect(
  37. Testcase{
  38. TensorValue(
  39. {1, 1, 3, 3},
  40. dtype::Quantized8Asymm{1.4f, static_cast<uint8_t>(127)},
  41. {131, 255, 180, 245, 8, 0, 10, 3, 178}),
  42. TensorValue(
  43. {1, 2, 3}, dtype::Float32{},
  44. {1.2f, 1.2f, 0.6f, -1.05f, -2.0f, -0.7f}),
  45. {}},
  46. Testcase{
  47. {},
  48. {},
  49. TensorValue(
  50. {1, 1, 2, 2},
  51. dtype::Quantized8Asymm{1.4f, static_cast<uint8_t>(127)},
  52. {205, 50, 101, 178})});
  53. }
  54. TEST_F(NAIVE_MULTI_THREADS, WARP_AFFINE_CV) {
  55. using namespace warp_affine;
  56. std::vector<TestArg> args = get_cv_args();
  57. Checker<WarpAffine> checker(handle());
  58. for (auto&& arg : args) {
  59. checker.set_param(arg.param)
  60. .set_dtype(0, dtype::Uint8())
  61. .set_dtype(1, dtype::Float32())
  62. .set_dtype(2, dtype::Uint8())
  63. .execs({arg.src, arg.trans, arg.dst});
  64. }
  65. for (auto&& arg : args) {
  66. checker.set_param(arg.param)
  67. .set_dtype(0, dtype::Float32())
  68. .set_dtype(1, dtype::Float32())
  69. .set_dtype(2, dtype::Float32())
  70. .execs({arg.src, arg.trans, arg.dst});
  71. }
  72. }
  73. // vim: syntax=cpp.doxygen

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