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.

opr_impl.cpp 2.9 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /**
  2. * \file dnn/src/armv7/matrix_mul/opr_impl.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
  10. * implied.
  11. */
  12. #include "src/armv7/matrix_mul/algos.h"
  13. #include "src/armv7/matrix_mul/opr_impl.h"
  14. #include "src/common/metahelper.h"
  15. #include "src/common/utils.h"
  16. #include "src/fallback/matrix_mul/gemm_impl.h"
  17. #include "src/naive/handle.h"
  18. using namespace megdnn;
  19. using namespace armv7;
  20. class MatrixMulImpl::AlgoPack : NonCopyableObj {
  21. AlgoF32 f32;
  22. AlgoF32MK4Pack4x12 f32_mk4_pack_4x12;
  23. AlgoF32MK4_4x8 f32_mk4_4x8;
  24. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  25. AlgoF16K4x16x1 f16_k4x16x1;
  26. AlgoF16MK8_4x8 f16_mk8_4x8;
  27. #endif
  28. #if __ARM_FEATURE_DOTPROD
  29. AlgoInt8x8x32K6x8x4 int8_k6x8x4;
  30. AlgoQuint8DotK4x8x4 quint8_k4x8x4;
  31. AlgoInt8x8x32MK4_8x4x4DotProd int8x8x32_mk4_8x4x4_dotprod;
  32. #endif
  33. AlgoF32Gemv f32_gemv;
  34. AlgoInt8x8x32MK4_4x2x16 int8x8x32_mk4_4x2x16;
  35. AlgoInt8x8x32K4x2x16 int8x8x32_k4x2x16;
  36. AlgoInt8x8x32K4x8x8 int8x8x32_k4x8x8;
  37. AlgoQuint8K4x8x8 quint8_k4x8x8;
  38. AlgoInt8x8x16K4x2x16 int8x8x16_k4x2x16;
  39. AlgoInt8x8x16K4x8x8 int8x8x16_k4x8x8;
  40. AlgoInt8x8x16MK4_8x8x4 int8x8x16_mk4_8x8x4;
  41. AlgoInt16x16x32K12x4x1 int16x16x32_k12x4x1;
  42. AlgoInt16x16x32MK8_4x8 int16x16x32_mk8_4x8;
  43. public:
  44. SmallVector<fallback::MatrixMulImpl::AlgoBase*> all_algos;
  45. AlgoPack() {
  46. all_algos.emplace_back(&f32_gemv);
  47. all_algos.emplace_back(&f32);
  48. all_algos.emplace_back(&f32_mk4_pack_4x12);
  49. all_algos.emplace_back(&f32_mk4_4x8);
  50. #if __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
  51. all_algos.emplace_back(&f16_k4x16x1);
  52. all_algos.emplace_back(&f16_mk8_4x8);
  53. #endif
  54. #if __ARM_FEATURE_DOTPROD
  55. all_algos.emplace_back(&int8x8x32_mk4_8x4x4_dotprod);
  56. all_algos.emplace_back(&int8_k6x8x4);
  57. all_algos.emplace_back(&quint8_k4x8x4);
  58. #endif
  59. all_algos.emplace_back(&int8x8x32_mk4_4x2x16);
  60. all_algos.emplace_back(&int8x8x32_k4x2x16);
  61. all_algos.emplace_back(&int8x8x32_k4x8x8);
  62. all_algos.emplace_back(&quint8_k4x8x8);
  63. all_algos.emplace_back(&int8x8x16_mk4_8x8x4);
  64. all_algos.emplace_back(&int8x8x16_k4x2x16);
  65. all_algos.emplace_back(&int8x8x16_k4x8x8);
  66. all_algos.emplace_back(&int16x16x32_k12x4x1);
  67. all_algos.emplace_back(&int16x16x32_mk8_4x8);
  68. }
  69. };
  70. SmallVector<fallback::MatrixMulImpl::AlgoBase*> MatrixMulImpl::algo_pack() {
  71. static AlgoPack s_algo_pack;
  72. auto algos = arm_common::MatrixMulImpl::algo_pack();
  73. algos.insert(algos.begin(), s_algo_pack.all_algos.begin(),
  74. s_algo_pack.all_algos.end());
  75. return algos;
  76. }
  77. // vim: syntax=cpp.doxygen

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