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

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

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