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

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. /**
  2. * \file dnn/src/armv7/conv_bias/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 implied.
  10. */
  11. #include "src/armv7/conv_bias/opr_impl.h"
  12. #include "src/armv7/conv_bias/int8/algos.h"
  13. #include "src/armv7/conv_bias/quint8/algos.h"
  14. #include "src/common/utils.h"
  15. #include "src/naive/handle.h"
  16. #include "src/common/metahelper.h"
  17. #include "src/fallback/convolution/opr_impl.h"
  18. using namespace megdnn;
  19. using namespace armv7;
  20. class ConvBiasImpl::AlgoPack : NonCopyableObj {
  21. AlgoS8MatrixMul s8_matrix_mul;
  22. AlgoQU8MatrixMul qu8_matrix_mul;
  23. fallback::ConvBiasImpl::AlgoBase::Mapper m_all_algos_map;
  24. SmallVector<fallback::ConvBiasImpl::AlgoBase*> m_all_algos;
  25. public:
  26. AlgoPack() {
  27. m_all_algos.emplace_back(&qu8_matrix_mul);
  28. m_all_algos.emplace_back(&s8_matrix_mul);
  29. for (auto&& algo : m_all_algos) {
  30. m_all_algos_map.emplace(algo->info().desc, algo);
  31. }
  32. }
  33. const SmallVector<fallback::ConvBiasImpl::AlgoBase*>& all_algos()
  34. const {
  35. return m_all_algos;
  36. }
  37. const AlgoBase::Mapper& all_algos_map() const { return m_all_algos_map; }
  38. };
  39. const ConvBiasImpl::AlgoPack& ConvBiasImpl::algo_pack() {
  40. static AlgoPack algo_pack;
  41. return algo_pack;
  42. }
  43. MEGDNN_FB_DEF_GET_ALGO_FROM_DESC(ConvBiasImpl)
  44. SmallVector<fallback::ConvBiasImpl::AlgoBase*>
  45. ConvBiasImpl::get_all_packed_algo() {
  46. auto&& algos = arm_common::ConvBiasImpl::get_all_packed_algo();
  47. //! TODO fused matmul bias is slower than matmul + elemwise in armv7 now,
  48. //! and nearly equal in aarch64, because of the waste of register in
  49. //! postprocess
  50. algos.insert(algos.end(), algo_pack().all_algos().begin(),
  51. algo_pack().all_algos().end());
  52. return std::move(algos);
  53. }
  54. const char* ConvBiasImpl::get_algorithm_set_name() const {
  55. return "ARMV7";
  56. }
  57. // vim: syntax=cpp.doxygen

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