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.

platform_info.h 7.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 PLATFORM_INFO_H
  17. #define PLATFORM_INFO_H
  18. #include <map>
  19. #include <string>
  20. #include "platform_info_def.h"
  21. #include "platform_infos_def.h"
  22. namespace fe {
  23. class PlatformInfoManager {
  24. public:
  25. PlatformInfoManager(const PlatformInfoManager &) = delete;
  26. PlatformInfoManager &operator=(const PlatformInfoManager &) = delete;
  27. static PlatformInfoManager &Instance();
  28. uint32_t InitializePlatformInfo();
  29. uint32_t Finalize();
  30. uint32_t GetPlatformInfo(const std::string SoCVersion,
  31. PlatformInfo &platform_info,
  32. OptionalInfo &opti_compilation_info);
  33. uint32_t GetPlatformInfoWithOutSocVersion(PlatformInfo &platform_info, OptionalInfo &opti_compilation_info);
  34. void SetOptionalCompilationInfo(OptionalInfo &opti_compilation_info);
  35. uint32_t GetPlatformInfos(const std::string SoCVersion,
  36. PlatFormInfos &platform_info,
  37. OptionalInfos &opti_compilation_info);
  38. uint32_t GetPlatformInfoWithOutSocVersion(PlatFormInfos &platform_info, OptionalInfos &opti_compilation_info);
  39. void SetOptionalCompilationInfo(OptionalInfos &opti_compilation_info);
  40. private:
  41. PlatformInfoManager();
  42. ~PlatformInfoManager();
  43. uint32_t LoadIniFile(std::string ini_file_real_path);
  44. void Trim(std::string &str);
  45. uint32_t LoadConfigFile(std::string real_path);
  46. std::string RealPath(const std::string &path);
  47. std::string GetSoFilePath();
  48. void ParseVersion(std::map<std::string, std::string> &version_map,
  49. std::string &soc_version,
  50. PlatformInfo &platform_info_temp);
  51. void ParseSocInfo(std::map<std::string, std::string> &soc_info_map,
  52. PlatformInfo &platform_info_temp);
  53. void ParseCubeOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  54. PlatformInfo &platform_info_temp);
  55. void ParseBufferOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  56. PlatformInfo &platform_info_temp);
  57. void ParseUBOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  58. PlatformInfo &platform_info_temp);
  59. void ParseUnzipOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  60. PlatformInfo &platform_info_temp);
  61. void ParseAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  62. PlatformInfo &platform_info_temp);
  63. void ParseBufferOfAICoreMemoryRates(std::map<std::string, std::string> &ai_core_memory_rates_map,
  64. PlatformInfo &platform_info_temp);
  65. void ParseAICoreMemoryRates(std::map<std::string, std::string> &ai_core_memory_rates_map,
  66. PlatformInfo &platform_info_temp);
  67. void ParseUBOfAICoreMemoryRates(std::map<std::string, std::string> &ai_core_memory_rates_map,
  68. PlatformInfo &platform_info_temp);
  69. void ParseAICoreintrinsicDtypeMap(std::map<std::string, std::string> &ai_coreintrinsic_dtype_map,
  70. PlatformInfo &platform_info_temp);
  71. void ParseVectorCoreSpec(std::map<std::string, std::string> &vector_core_spec_map,
  72. PlatformInfo &platform_info_temp);
  73. void ParseVectorCoreMemoryRates(std::map<std::string, std::string> &vector_core_memory_rates_map,
  74. PlatformInfo &platform_info_temp);
  75. void ParseCPUCache(std::map<std::string, std::string> &CPUCacheMap,
  76. PlatformInfo &platform_info_temp);
  77. void ParseVectorCoreintrinsicDtypeMap(std::map<std::string, std::string> &vector_coreintrinsic_dtype_map,
  78. PlatformInfo &platform_info_temp);
  79. uint32_t ParsePlatformInfoFromStrToStruct(std::map<std::string, std::map<std::string, std::string>> &content_info_map,
  80. std::string &soc_version,
  81. PlatformInfo &platform_info_temp);
  82. void ParseVersion(std::map<std::string, std::string> &version_map,
  83. std::string &soc_version,
  84. PlatFormInfos &platform_info_temp);
  85. void ParseSocInfo(std::map<std::string, std::string> &soc_info_map, PlatFormInfos &platform_info_temp);
  86. void ParseCubeOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  87. PlatFormInfos &platform_info_temp);
  88. void ParseBufferOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  89. PlatFormInfos &platform_info_temp);
  90. void ParseUBOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  91. PlatFormInfos &platform_info_temp);
  92. void ParseUnzipOfAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  93. PlatFormInfos &platform_info_temp);
  94. void ParseAICoreSpec(std::map<std::string, std::string> &ai_core_spec_map,
  95. PlatFormInfos &platform_info_temp);
  96. void ParseBufferOfAICoreMemoryRates(std::map<std::string, std::string> &ai_core_memory_rates_map,
  97. PlatFormInfos &platform_info_temp);
  98. void ParseAICoreMemoryRates(std::map<std::string, std::string> &ai_core_memory_rates_map,
  99. PlatFormInfos &platform_info_temp);
  100. void ParseUBOfAICoreMemoryRates(std::map<std::string, std::string> &ai_core_memory_rates_map,
  101. PlatFormInfos &platform_info_temp);
  102. void ParseAICoreintrinsicDtypeMap(std::map<std::string, std::string> &ai_coreintrinsic_dtype_map,
  103. PlatFormInfos &platform_info_temp);
  104. void ParseVectorCoreSpec(std::map<std::string, std::string> &vector_core_spec_map,
  105. PlatFormInfos &platform_info_temp);
  106. void ParseVectorCoreMemoryRates(std::map<std::string, std::string> &vector_core_memory_rates_map,
  107. PlatFormInfos &platform_info_temp);
  108. void ParseCPUCache(std::map<std::string, std::string> &CPUCacheMap,
  109. PlatFormInfos &platform_info_temp);
  110. void ParseVectorCoreintrinsicDtypeMap(std::map<std::string, std::string> &vector_coreintrinsic_dtype_map,
  111. PlatFormInfos &platform_info_temp);
  112. uint32_t ParsePlatformInfo(std::map<std::string, std::map<std::string, std::string>> &content_info_map,
  113. std::string &soc_version,
  114. PlatFormInfos &platform_info_temp);
  115. uint32_t AssemblePlatformInfoVector(std::map<std::string, std::map<std::string, std::string>> &content_info_map);
  116. private:
  117. bool init_flag_;
  118. std::map<std::string, PlatformInfo> platform_info_map_;
  119. OptionalInfo opti_compilation_info_;
  120. std::map<std::string, PlatFormInfos> platform_infos_map_;
  121. OptionalInfos opti_compilation_infos_;
  122. };
  123. } // namespace fe
  124. #endif

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