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.

dnnengines.h 4.4 kB

5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. /**
  2. * Copyright 2019-2020 Huawei Technologies Co., Ltd
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #ifndef GE_PLUGIN_ENGINE_DNNENGINES_H_
  17. #define GE_PLUGIN_ENGINE_DNNENGINES_H_
  18. #include <map>
  19. #include <memory>
  20. #include <string>
  21. #include "engine/dnnengine.h"
  22. #include "plugin/engine/engine_manage.h"
  23. namespace ge {
  24. class AICoreDNNEngine : public DNNEngine {
  25. public:
  26. AICoreDNNEngine() = default;
  27. explicit AICoreDNNEngine(const std::string &engine_name);
  28. explicit AICoreDNNEngine(const DNNEngineAttribute &attrs);
  29. ~AICoreDNNEngine() = default;
  30. Status Initialize(const std::map<std::string, std::string> &options);
  31. Status Finalize();
  32. void GetAttributes(DNNEngineAttribute &attr) const;
  33. private:
  34. DNNEngineAttribute engine_attribute_;
  35. };
  36. class VectorCoreDNNEngine : public DNNEngine {
  37. public:
  38. VectorCoreDNNEngine() = default;
  39. explicit VectorCoreDNNEngine(const std::string &engine_name);
  40. explicit VectorCoreDNNEngine(const DNNEngineAttribute &attrs);
  41. ~VectorCoreDNNEngine() = default;
  42. Status Initialize(const std::map<std::string, std::string> &options);
  43. Status Finalize();
  44. void GetAttributes(DNNEngineAttribute &attr) const;
  45. private:
  46. DNNEngineAttribute engine_attribute_;
  47. };
  48. class AICpuDNNEngine : public DNNEngine {
  49. public:
  50. AICpuDNNEngine() = default;
  51. explicit AICpuDNNEngine(const std::string &engine_name);
  52. explicit AICpuDNNEngine(const DNNEngineAttribute &attrs);
  53. ~AICpuDNNEngine() = default;
  54. Status Initialize(const std::map<std::string, std::string> &options);
  55. Status Finalize();
  56. void GetAttributes(DNNEngineAttribute &attr) const;
  57. private:
  58. DNNEngineAttribute engine_attribute_;
  59. };
  60. class AICpuTFDNNEngine : public DNNEngine {
  61. public:
  62. AICpuTFDNNEngine() = default;
  63. explicit AICpuTFDNNEngine(const std::string &engine_name);
  64. explicit AICpuTFDNNEngine(const DNNEngineAttribute &attrs);
  65. ~AICpuTFDNNEngine() = default;
  66. Status Initialize(const std::map<std::string, std::string> &options);
  67. Status Finalize();
  68. void GetAttributes(DNNEngineAttribute &attr) const;
  69. private:
  70. DNNEngineAttribute engine_attribute_;
  71. };
  72. class GeLocalDNNEngine : public DNNEngine {
  73. public:
  74. GeLocalDNNEngine() = default;
  75. explicit GeLocalDNNEngine(const std::string &engine_name);
  76. explicit GeLocalDNNEngine(const DNNEngineAttribute &attrs);
  77. ~GeLocalDNNEngine() = default;
  78. Status Initialize(const std::map<std::string, std::string> &options);
  79. Status Finalize();
  80. void GetAttributes(DNNEngineAttribute &attr) const;
  81. private:
  82. DNNEngineAttribute engine_attribute_;
  83. };
  84. class HostCpuDNNEngine : public DNNEngine {
  85. public:
  86. HostCpuDNNEngine() = default;
  87. explicit HostCpuDNNEngine(const std::string &engine_name);
  88. explicit HostCpuDNNEngine(const DNNEngineAttribute &attrs);
  89. ~HostCpuDNNEngine() = default;
  90. Status Initialize(const std::map<std::string, std::string> &options);
  91. Status Finalize();
  92. void GetAttributes(DNNEngineAttribute &attr) const;
  93. private:
  94. DNNEngineAttribute engine_attribute_;
  95. };
  96. class RtsDNNEngine : public DNNEngine {
  97. public:
  98. RtsDNNEngine() = default;
  99. explicit RtsDNNEngine(const std::string &engine_name);
  100. explicit RtsDNNEngine(const DNNEngineAttribute &attrs);
  101. ~RtsDNNEngine() = default;
  102. Status Initialize(const std::map<std::string, std::string> &options);
  103. Status Finalize();
  104. void GetAttributes(DNNEngineAttribute &attr) const;
  105. private:
  106. DNNEngineAttribute engine_attribute_;
  107. };
  108. class HcclDNNEngine : public DNNEngine {
  109. public:
  110. HcclDNNEngine() = default;
  111. explicit HcclDNNEngine(const std::string &engine_name);
  112. explicit HcclDNNEngine(const DNNEngineAttribute &attrs);
  113. ~HcclDNNEngine() = default;
  114. Status Initialize(const std::map<std::string, std::string> &options);
  115. Status Finalize();
  116. void GetAttributes(DNNEngineAttribute &attr) const;
  117. private:
  118. DNNEngineAttribute engine_attribute_;
  119. };
  120. } // namespace ge
  121. #endif // GE_PLUGIN_ENGINE_DNNENGINES_H_

图引擎模块(GE)是MindSpore的一个子模块,其代码由C++实现,位于前端模块ME和底层硬件之间,起到承接作用。图引擎模块以ME下发的图作为输入,然后进行一系列的深度图优化操作,最后输出一张可以在底层硬件上高效运行的图。GE针对昇腾AI处理器的硬件结构特点,做了特定的优化工作,以此来充分发挥出昇腾AI处理器的强大算力。在进行模型训练/推理时,GE会被自动调用而用户并不感知。GE主要由GE API和GE Core两部分组成,详细的架构图如下所示