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.

properties_manager.h 4.1 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_COMMON_PROPERTIES_MANAGER_H_
  17. #define GE_COMMON_PROPERTIES_MANAGER_H_
  18. #include <map>
  19. #include <mutex>
  20. #include <set>
  21. #include <string>
  22. #include <vector>
  23. #include "graph/op_desc.h"
  24. namespace ge {
  25. // Configuration property management
  26. static const char *SYSMODE __attribute__((unused)) = "FMK_SYSMODE";
  27. static const char *USE_FUSION __attribute__((unused)) = "FMK_USE_FUSION";
  28. static const char *TIMESTAT_ENABLE __attribute__((unused)) = "DAVINCI_TIMESTAT_ENABLE";
  29. static const char *ANNDROID_DEBUG __attribute__((unused)) = "ANNDROID_DEBUG";
  30. class PropertiesManager {
  31. public:
  32. // Singleton
  33. static PropertiesManager &Instance();
  34. /**
  35. * @ingroup domi_ome
  36. * @brief Initialize configuration parameters, which must be invoked in main.
  37. * @param [in] file_path Property profile path
  38. * @return true success
  39. * @return false fail
  40. * @author
  41. */
  42. bool Init(const std::string &file_path);
  43. /**
  44. * @ingroup domi_ome
  45. * @brief Get configuration parameter value
  46. * @param [in] key Configuration parameter name
  47. * @return Configuration parameter value. If the parameter name does not exist, return null
  48. * @author
  49. */
  50. std::string GetPropertyValue(const std::string &key);
  51. /**
  52. * @ingroup domi_ome
  53. * @brief Set configuration parameters
  54. * @param [in] key Configuration parameter name
  55. * @param [out] key Configuration parameter value
  56. * @author
  57. */
  58. void SetPropertyValue(const std::string &key, const std::string &value);
  59. /**
  60. * @ingroup domi_ome
  61. * @brief Return configuration parameters
  62. * @return properties_map_
  63. * @author
  64. */
  65. std::map<std::string, std::string> GetPropertyMap();
  66. /**
  67. * @ingroup domi_ome
  68. * @brief Adapt key value pair form, set different separators
  69. * @param [in] delimiter
  70. * @author
  71. */
  72. void SetPropertyDelimiter(const std::string &de);
  73. void AddDumpPropertyValue(const std::string &model, const std::set<std::string> &layers);
  74. std::set<std::string> GetAllDumpModel();
  75. std::set<std::string> GetDumpPropertyValue(const std::string &model);
  76. bool IsLayerNeedDump(const std::string &model, const std::string &om_name, const std::string &op_name);
  77. void DeleteDumpPropertyValue(const std::string &model);
  78. void ClearDumpPropertyValue();
  79. bool QueryModelDumpStatus(const std::string &model);
  80. void SetDumpOutputModel(const std::string &output_model);
  81. std::string GetDumpOutputModel();
  82. void SetDumpOutputPath(const std::string &output_path);
  83. std::string GetDumpOutputPath();
  84. void SetDumpStep(const std::string &dump_step);
  85. std::string GetDumpStep();
  86. void SetDumpMode(const std::string &dump_mode);
  87. std::string GetDumpMode();
  88. private:
  89. // Private construct, destructor
  90. PropertiesManager();
  91. ~PropertiesManager();
  92. // Get file content
  93. bool LoadFileContent(const std::string &file_path);
  94. // Parsing a single line file
  95. bool ParseLine(const std::string &line);
  96. // Remove space before and after string
  97. std::string Trim(const std::string &str);
  98. bool is_inited_;
  99. // Configuration item separator, default is "="
  100. std::string delimiter;
  101. std::map<std::string, std::string> properties_map_;
  102. std::mutex mutex_;
  103. std::string output_mode_;
  104. std::string output_path_;
  105. std::string dump_step_;
  106. std::string dump_mode_;
  107. std::map<std::string, std::set<std::string>> model_dump_properties_map_; // model_dump_layers_map_
  108. std::mutex dump_mutex_;
  109. };
  110. } // namespace ge
  111. #endif // GE_COMMON_PROPERTIES_MANAGER_H_

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