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

5 years ago
5 years ago
5 years ago
4 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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 "graph/tuning_utils.h"
  25. #include "graph/operator_factory.h"
  26. #include "graph/ge_local_context.h"
  27. #include "graph/debug/ge_attr_define.h"
  28. #include "graph/utils/graph_utils.h"
  29. #include "graph/utils/anchor_utils.h"
  30. #include "framework/common/ge_inner_error_codes.h"
  31. #include "framework/common/ge_types.h"
  32. using std::string;
  33. using std::map;
  34. using std::vector;
  35. namespace ge {
  36. class GE_FUNC_VISIBILITY GELib {
  37. public:
  38. GELib() = default;
  39. ~GELib() = default;
  40. // get GELib singleton instance
  41. static std::shared_ptr<GELib> GetInstance();
  42. // GE Environment Initialize, return Status: SUCCESS,FAILED
  43. static Status Initialize(const map<string, string> &options);
  44. static string GetPath();
  45. // GE Environment Finalize, return Status: SUCCESS,FAILED
  46. Status Finalize();
  47. // get DNNEngineManager object
  48. DNNEngineManager &DNNEngineManagerObj() { return engineManager_; }
  49. // get OpsKernelManager object
  50. OpsKernelManager &OpsKernelManagerObj() { return opsManager_; }
  51. // get Initial flag
  52. bool InitFlag() const { return init_flag_; }
  53. // get TrainMode flag
  54. bool IsTrainMode() { return is_train_mode_; }
  55. void InitProfiling(Options &options);
  56. void ShutDownProfiling();
  57. Status InitSystemWithoutOptions();
  58. Status InitSystemWithOptions(Options &options);
  59. Status SystemShutdownWithOptions(const Options &options);
  60. private:
  61. GELib(const GELib &);
  62. const GELib &operator=(const GELib &);
  63. Status InnerInitialize(const map<string, string> &options);
  64. Status SystemInitialize(const map<string, string> &options);
  65. Status SetRTSocVersion(const map<string, string> &options, map<string, string> &new_options);
  66. Status SetAiCoreNum(map<string, string> &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. std::mutex status_mutex_;
  75. bool init_flag_ = false;
  76. Options options_;
  77. bool is_train_mode_ = false;
  78. bool is_system_inited = false;
  79. bool is_shutdown = false;
  80. bool is_use_hcom = false;
  81. };
  82. } // namespace ge
  83. #endif // GE_INIT_GELIB_H_

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