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 3.5 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /**
  2. * Copyright 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 "common/dump/dump_properties.h"
  24. #include "graph/op_desc.h"
  25. #include "common/ge_compiler_options.h"
  26. namespace ge {
  27. // Configuration property management
  28. static const char *SYSMODE GE_ATTRIBUTE_UNUSED = "FMK_SYSMODE";
  29. static const char *USE_FUSION GE_ATTRIBUTE_UNUSED = "FMK_USE_FUSION";
  30. static const char *TIMESTAT_ENABLE GE_ATTRIBUTE_UNUSED = "DAVINCI_TIMESTAT_ENABLE";
  31. static const char *ANNDROID_DEBUG GE_ATTRIBUTE_UNUSED = "ANNDROID_DEBUG";
  32. class PropertiesManager {
  33. public:
  34. // Singleton
  35. static PropertiesManager &Instance();
  36. /**
  37. * @ingroup domi_ome
  38. * @brief Initialize configuration parameters, which must be invoked in main.
  39. * @param [in] file_path Property profile path
  40. * @return true success
  41. * @return false fail
  42. * @author
  43. */
  44. bool Init(const std::string &file_path);
  45. /**
  46. * @ingroup domi_ome
  47. * @brief Get configuration parameter value
  48. * @param [in] key Configuration parameter name
  49. * @return Configuration parameter value. If the parameter name does not exist, return null
  50. * @author
  51. */
  52. std::string GetPropertyValue(const std::string &key);
  53. /**
  54. * @ingroup domi_ome
  55. * @brief Set configuration parameters
  56. * @param [in] key Configuration parameter name
  57. * @param [out] key Configuration parameter value
  58. * @author
  59. */
  60. void SetPropertyValue(const std::string &key, const std::string &value);
  61. /**
  62. * @ingroup domi_ome
  63. * @brief Return configuration parameters
  64. * @return properties_map_
  65. * @author
  66. */
  67. std::map<std::string, std::string> GetPropertyMap();
  68. /**
  69. * @ingroup domi_ome
  70. * @brief Adapt key value pair form, set different separators
  71. * @param [in] delimiter
  72. * @author
  73. */
  74. void SetPropertyDelimiter(const std::string &de);
  75. DumpProperties &GetDumpProperties(uint64_t session_id);
  76. const map<uint64_t, DumpProperties> &GetDumpPropertiesMap() { return dump_properties_map_; }
  77. void AddDumpProperties(uint64_t session_id, const DumpProperties &dump_properties);
  78. void RemoveDumpProperties(uint64_t session_id);
  79. private:
  80. // Private construct, destructor
  81. PropertiesManager();
  82. ~PropertiesManager();
  83. // Get file content
  84. bool LoadFileContent(const std::string &file_path);
  85. // Parsing a single line file
  86. bool ParseLine(const std::string &line);
  87. // Remove space before and after string
  88. std::string Trim(const std::string &str);
  89. bool is_inited_;
  90. // Configuration item separator, default is "="
  91. std::string delimiter;
  92. std::map<std::string, std::string> properties_map_;
  93. std::mutex mutex_;
  94. std::map<uint64_t, DumpProperties> dump_properties_map_;
  95. };
  96. } // namespace ge
  97. #endif // GE_COMMON_PROPERTIES_MANAGER_H_

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