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.

ops_kernel_info_store.h 2.7 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /**
  2. * Copyright 2020 Huawei Technologies Co., Ltd
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. * http://www.apache.org/licenses/LICENSE-2.0
  7. * Unless required by applicable law or agreed to in writing, software
  8. * distributed under the License is distributed on an "AS IS" BASIS,
  9. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. * See the License for the specific language governing permissions and
  11. * limitations under the License.
  12. */
  13. #ifndef INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_
  14. #define INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_
  15. #include <iostream>
  16. #include <map>
  17. #include <string>
  18. #include <vector>
  19. #include "./ge_task_info.h"
  20. #include "./ops_kernel_info_types.h"
  21. #include "cce/aicpu_engine_struct.h"
  22. #include "cce/fwk_adpt_struct.h"
  23. #include "common/ge_inner_error_codes.h"
  24. #include "graph/node.h"
  25. #include "proto/task.pb.h"
  26. using std::map;
  27. using std::string;
  28. using std::to_string;
  29. using std::vector;
  30. namespace ge {
  31. class OpDesc;
  32. class OpsKernelInfoStore {
  33. public:
  34. OpsKernelInfoStore() {}
  35. virtual ~OpsKernelInfoStore() {}
  36. // initialize opsKernelInfoStore
  37. virtual Status Initialize(const map<string, string> &options) = 0; /*lint -e148*/
  38. // close opsKernelInfoStore
  39. virtual Status Finalize() = 0; /*lint -e148*/
  40. virtual Status CreateSession(const std::map<std::string, std::string> &session_options) { return SUCCESS; }
  41. virtual Status DestroySession(const std::map<std::string, std::string> &session_options) { return SUCCESS; }
  42. // get all opsKernelInfo
  43. virtual void GetAllOpsKernelInfo(map<string, OpInfo> &infos) const = 0;
  44. // whether the opsKernelInfoStore is supported based on the operator attribute
  45. virtual bool CheckSupported(const OpDescPtr &opDescPtr, std::string &un_supported_reason) const = 0;
  46. virtual bool CheckAccuracySupported(const OpDescPtr &opDescPtr, std::string &un_supported_reason,
  47. bool realQuery = false) const {
  48. return CheckSupported(opDescPtr, un_supported_reason);
  49. }
  50. // opsFlag opsFlag[0] indicates constant folding is supported or not
  51. virtual void opsFlagCheck(const ge::Node &node, std::string &opsFlag) {};
  52. // only call fe engine interface to compile single op
  53. virtual Status CompileOp(vector<ge::NodePtr> &node_vec) { return SUCCESS; }
  54. virtual Status CompileOpRun(vector<ge::NodePtr> &node_vec) { return SUCCESS; }
  55. // load task for op
  56. virtual Status LoadTask(GETaskInfo &task) { return SUCCESS; }
  57. };
  58. } // namespace ge
  59. #endif // INC_COMMON_OPSKERNEL_OPS_KERNEL_INFO_STORE_H_

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