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.

imgproc.sereg.h 4.2 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. /**
  2. * \file src/opr/impl/imgproc.sereg.h
  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 "megbrain/opr/imgproc.h"
  12. #include "megbrain/serialization/sereg.h"
  13. namespace mgb {
  14. namespace serialization {
  15. //! OprMaker implementation for operators with variadic arguments
  16. template<>
  17. struct OprMaker<opr::WarpPerspective, 0> {
  18. using Opr = opr::WarpPerspective;
  19. using Param = Opr::Param;
  20. static cg::OperatorNodeBase* make(const Param& param,
  21. const cg::VarNodeArray& inputs,
  22. ComputingGraph& graph,
  23. const OperatorNodeConfig& config) {
  24. MGB_MARK_USED_VAR(graph);
  25. if (inputs.size() == 3) {
  26. return Opr::make(inputs[0], inputs[1], inputs[2], param, config)
  27. .node()
  28. ->owner_opr();
  29. } else {
  30. mgb_assert(inputs.size() == 4);
  31. return Opr::make(inputs[0], inputs[1], inputs[2], inputs[3],
  32. param, config)
  33. .node()
  34. ->owner_opr();
  35. }
  36. }
  37. };
  38. template<>
  39. struct OprMaker<opr::WarpPerspectiveBackwardData, 0> {
  40. using Opr = opr::WarpPerspectiveBackwardData;
  41. using Param = Opr::Param;
  42. static cg::OperatorNodeBase* make(const Param& param,
  43. const cg::VarNodeArray& inputs,
  44. ComputingGraph& graph,
  45. const OperatorNodeConfig& config) {
  46. MGB_MARK_USED_VAR(graph);
  47. if (inputs.size() == 3) {
  48. return Opr::make(inputs[0], inputs[1], inputs[2], param, config)
  49. .node()
  50. ->owner_opr();
  51. } else {
  52. mgb_assert(inputs.size() == 4);
  53. return Opr::make(inputs[0], inputs[1], inputs[2], inputs[3],
  54. param, config)
  55. .node()
  56. ->owner_opr();
  57. }
  58. }
  59. };
  60. template<>
  61. struct OprMaker<opr::WarpPerspectiveBackwardMat, 0> {
  62. using Opr = opr::WarpPerspectiveBackwardMat;
  63. using Param = Opr::Param;
  64. static cg::OperatorNodeBase* make(const Param& param,
  65. const cg::VarNodeArray& inputs,
  66. ComputingGraph& graph,
  67. const OperatorNodeConfig& config) {
  68. MGB_MARK_USED_VAR(graph);
  69. if (inputs.size() == 3) {
  70. return Opr::make(inputs[0], inputs[1], inputs[2], param, config)
  71. .node()
  72. ->owner_opr();
  73. } else {
  74. mgb_assert(inputs.size() == 4);
  75. return Opr::make(inputs[0], inputs[1], inputs[2], inputs[3],
  76. param, config)
  77. .node()
  78. ->owner_opr();
  79. }
  80. }
  81. };
  82. } // namespace serialization
  83. namespace opr {
  84. MGB_SEREG_OPR(WarpPerspective, 0);
  85. MGB_SEREG_OPR(WarpPerspectiveBackwardData, 0);
  86. MGB_SEREG_OPR(WarpPerspectiveBackwardMat, 0);
  87. MGB_SEREG_OPR(Rotate, 1);
  88. MGB_SEREG_OPR(CvtColor, 1);
  89. MGB_SEREG_OPR(GaussianBlur, 1);
  90. MGB_SEREG_OPR(ResizeBackward, 2);
  91. MGB_SEREG_OPR(Remap, 2);
  92. MGB_SEREG_OPR(RemapBackwardData, 3);
  93. MGB_SEREG_OPR(RemapBackwardMat, 3);
  94. //! current warp affine version
  95. using WarpAffineV1 = opr::WarpAffine;
  96. MGB_SEREG_OPR(WarpAffineV1, 3);
  97. //! current resize version
  98. using ResizeV1 = opr::Resize;
  99. MGB_SEREG_OPR(ResizeV1, 2);
  100. } // namespace opr
  101. } // namespace mgb
  102. // vim: ft=cpp syntax=cpp.doxygen foldmethod=marker foldmarker=f{{{,f}}}

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