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.

gelib.h 3.2 kB

5 years ago
5 years ago
4 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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_INIT_GELIB_H_
  17. #define GE_INIT_GELIB_H_
  18. #include <map>
  19. #include <memory>
  20. #include <string>
  21. #include <vector>
  22. #include "engine_manager/dnnengine_manager.h"
  23. #include "opskernel_manager/ops_kernel_manager.h"
  24. #include "session/session_manager.h"
  25. #include "common/ge_inner_error_codes.h"
  26. #include "common/ge_types.h"
  27. using std::string;
  28. using std::map;
  29. using std::vector;
  30. namespace ge {
  31. class GELib {
  32. public:
  33. GELib() = default;
  34. ~GELib() = default;
  35. // get GELib singleton instance
  36. static std::shared_ptr<GELib> GetInstance();
  37. // GE Environment Initialize, return Status: SUCCESS,FAILED
  38. static Status Initialize(const map<string, string> &options);
  39. static string GetPath();
  40. // GE Environment Finalize, return Status: SUCCESS,FAILED
  41. Status Finalize();
  42. // get DNNEngineManager object
  43. DNNEngineManager &DNNEngineManagerObj() { return engineManager_; }
  44. // get OpsKernelManager object
  45. OpsKernelManager &OpsKernelManagerObj() { return opsManager_; }
  46. // get SessionManager object
  47. SessionManager &SessionManagerObj() { return sessionManager_; }
  48. // get Initial flag
  49. bool InitFlag() const { return init_flag_; }
  50. // get TrainMode flag
  51. bool isTrainMode() { return is_train_mode_; }
  52. // get incre build flag
  53. bool IsIncreBuild() const { return is_incre_build_; }
  54. // get incre build cache path
  55. const std::string &GetIncreBuildCachePath() const { return incre_build_cache_path_; }
  56. void InitProfiling(Options &options);
  57. void ShutDownProfiling();
  58. Status InitSystemWithoutOptions();
  59. Status InitSystemWithOptions(Options &options);
  60. Status SystemShutdownWithOptions(const Options &options);
  61. private:
  62. GELib(const GELib &);
  63. const GELib &operator=(const GELib &);
  64. Status InnerInitialize(const map<string, string> &options);
  65. Status SystemInitialize(const map<string, string> &options);
  66. Status SetRTSocVersion(const map<string, string> &options, map<string, string> &new_options);
  67. void SetDefaultPrecisionMode(map<string, string> &new_options);
  68. void RollbackInit();
  69. void InitOptions(const map<string, string> &options);
  70. void SetDumpModelOptions(const map<string, string> &options);
  71. void SetOpDebugOptions(const map<string, string> &options);
  72. DNNEngineManager engineManager_;
  73. OpsKernelManager opsManager_;
  74. SessionManager sessionManager_;
  75. std::mutex status_mutex_;
  76. bool init_flag_ = false;
  77. Options options_;
  78. bool is_train_mode_ = false;
  79. bool is_system_inited = false;
  80. bool is_shutdown = false;
  81. bool is_use_hcom = false;
  82. bool is_incre_build_ = false;
  83. std::string incre_build_cache_path_;
  84. };
  85. } // namespace ge
  86. #endif // GE_INIT_GELIB_H_

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