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.

algos.cpp 3.0 kB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /**
  2. * \file dnn/src/arm_common/convolution/quint8/algos.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 "src/arm_common/convolution/img2col_helper.h"
  12. #include "src/arm_common/convolution/quint8/algos.h"
  13. #include "src/arm_common/convolution/quint8/conv_backdata_stride1.h"
  14. #include "src/arm_common/convolution/quint8/conv_backdata_stride2.h"
  15. #include "src/common/opr_delegate.h"
  16. #include "midout.h"
  17. MIDOUT_DECL(megdnn_arm_conv_quint8_kimpl)
  18. using namespace megdnn;
  19. using namespace arm_common;
  20. #if __ARM_FEATURE_DOTPROD
  21. /* ===================== ConvolutionBackwardData ===================== */
  22. /* ===================== direct stride 1 algo ===================== */
  23. bool ConvolutionBackwardDataImpl::AlgoUdot8DirectStride1::usable(
  24. ConvolutionBackwardDataImpl*, const NCBKernSizeParam& param) const {
  25. return deconv::can_stride1_quint8_dot(param);
  26. }
  27. size_t ConvolutionBackwardDataImpl::AlgoUdot8DirectStride1::get_workspace(
  28. ConvolutionBackwardDataImpl*, const NCBKernSizeParam& param) const {
  29. MIDOUT_BEGIN(megdnn_arm_conv_quint8_kimpl,
  30. midout_iv("AlgoUdot8DirectStride1::get_workspace"_hash)) {
  31. return deconv::get_workspace_in_bytes_stride1_quint8_dot(param);
  32. }
  33. MIDOUT_END();
  34. return 0;
  35. }
  36. ConvolutionBackwardDataImpl::ncb_kern_t
  37. ConvolutionBackwardDataImpl::AlgoUdot8DirectStride1::dispatch_kern(
  38. ConvolutionBackwardDataImpl*, const NCBKernSizeParam&) const {
  39. MIDOUT_BEGIN(megdnn_arm_conv_quint8_kimpl,
  40. midout_iv("AlgoUdot8DirectStride1::dispatch_kern"_hash)) {
  41. return deconv::stride1_quint8_dot;
  42. }
  43. MIDOUT_END();
  44. return {};
  45. }
  46. /* ===================== direct stride 2 algo ===================== */
  47. bool ConvolutionBackwardDataImpl::AlgoUdot8DirectStride2::usable(
  48. ConvolutionBackwardDataImpl*, const NCBKernSizeParam& param) const {
  49. return deconv::can_stride2_quint8_dot(param);
  50. }
  51. size_t ConvolutionBackwardDataImpl::AlgoUdot8DirectStride2::get_workspace(
  52. ConvolutionBackwardDataImpl*, const NCBKernSizeParam& param) const {
  53. MIDOUT_BEGIN(megdnn_arm_conv_quint8_kimpl,
  54. midout_iv("AlgoUdot8DirectStride2::get_workspace"_hash)) {
  55. return deconv::get_workspace_in_bytes_stride2_quint8_dot(param);
  56. }
  57. MIDOUT_END();
  58. return 0;
  59. }
  60. ConvolutionBackwardDataImpl::ncb_kern_t
  61. ConvolutionBackwardDataImpl::AlgoUdot8DirectStride2::dispatch_kern(
  62. ConvolutionBackwardDataImpl*, const NCBKernSizeParam&) const {
  63. MIDOUT_BEGIN(megdnn_arm_conv_quint8_kimpl,
  64. midout_iv("AlgoUdot8DirectStride2::dispatch_kern"_hash)) {
  65. return deconv::stride2_quint8_dot;
  66. }
  67. MIDOUT_END();
  68. return {};
  69. }
  70. #endif
  71. // vim: syntax=cpp.doxygen

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