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_affine.h 3.2 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. /**
  2. * \file dnn/test/common/warp_affine.h
  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. #pragma once
  12. #include "megdnn/basic_types.h"
  13. #include "megdnn/opr_param_defs.h"
  14. #include "test/common/opr_proxy.h"
  15. #include <iostream>
  16. namespace megdnn {
  17. namespace test {
  18. namespace warp_affine {
  19. struct TestArg {
  20. param::WarpAffine param;
  21. TensorShape src;
  22. TensorShape trans;
  23. TensorShape dst;
  24. TestArg(param::WarpAffine param_, TensorShape src_, TensorShape trans_,
  25. TensorShape dst_)
  26. : param(param_), src(src_), trans(trans_), dst(dst_) {}
  27. };
  28. inline std::vector<TestArg> get_cv_args() {
  29. std::vector<TestArg> args;
  30. //! if the format of WarpAffine is NHWC, not support LINEAR and AREA
  31. using BorderMode = param::WarpAffine::BorderMode;
  32. using InterpolationMode = param::WarpAffine::InterpolationMode;
  33. param::WarpAffine cur_param;
  34. cur_param.format = param::WarpAffine::Format::NHWC;
  35. for (size_t i = 4; i <= 168; i *= 8) {
  36. for (size_t ic : {1, 2, 3}) {
  37. for (BorderMode bmode :
  38. {BorderMode::BORDER_REPLICATE, BorderMode::BORDER_REFLECT,
  39. BorderMode::BORDER_REFLECT_101, BorderMode::BORDER_WRAP,
  40. BorderMode::BORDER_CONSTANT}) {
  41. for (InterpolationMode imode :
  42. {InterpolationMode::LINEAR, InterpolationMode::INTER_NEAREST,
  43. InterpolationMode::INTER_CUBIC,
  44. InterpolationMode::INTER_LANCZOS4}) {
  45. cur_param.border_mode = bmode;
  46. cur_param.border_val = 1.1f;
  47. cur_param.imode = imode;
  48. args.emplace_back(
  49. cur_param, TensorShape{1, i, i, ic}, TensorShape{1, 2, 3},
  50. TensorShape{1, i, i, ic});
  51. args.emplace_back(
  52. cur_param, TensorShape{1, i, i * 2, ic},
  53. TensorShape{1, 2, 3}, TensorShape{1, i, i * 2, ic});
  54. args.emplace_back(
  55. cur_param, TensorShape{1, i * 3, i, ic},
  56. TensorShape{1, 2, 3}, TensorShape{1, i * 3, i, ic});
  57. args.emplace_back(
  58. cur_param, TensorShape{1, i, i, ic}, TensorShape{1, 2, 3},
  59. TensorShape{1, 8, 8, ic});
  60. args.emplace_back(
  61. cur_param, TensorShape{1, i, i * 2, ic},
  62. TensorShape{1, 2, 3}, TensorShape{1, 8, 8, ic});
  63. args.emplace_back(
  64. cur_param, TensorShape{1, i * 3, i, ic},
  65. TensorShape{1, 2, 3}, TensorShape{1, 8, 8, ic});
  66. }
  67. }
  68. }
  69. }
  70. return args;
  71. }
  72. } // namespace warp_affine
  73. } // namespace test
  74. } // namespace megdnn
  75. // vim: syntax=cpp.doxygen

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