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.

util_insert_aipp_op.h 2.8 kB

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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  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_GRAPH_PREPROCESS_INSERT_OP_UTIL_INSERT_AIPP_OP_H_
  17. #define GE_GRAPH_PREPROCESS_INSERT_OP_UTIL_INSERT_AIPP_OP_H_
  18. #include <memory>
  19. #include <string>
  20. #include <vector>
  21. #include "graph/compute_graph.h"
  22. #include "graph/preprocess/insert_op/base_insert_op.h"
  23. #include "proto/insert_op.pb.h"
  24. namespace ge {
  25. enum AippType { OLD_TYPE, NEW_TYPE };
  26. class InsertNewOpUtil {
  27. public:
  28. static InsertNewOpUtil &Instance() {
  29. thread_local InsertNewOpUtil instance;
  30. return instance;
  31. }
  32. Status Init();
  33. Status Parse(const char *conf_path);
  34. Status InsertAippOps(ge::ComputeGraphPtr &graph, std::string &aippConfigPath);
  35. void ClearNewOps();
  36. Status UpdateDataNodeByAipp(const ComputeGraphPtr &graph);
  37. Status RecordAIPPInfoToData(const ComputeGraphPtr &graph);
  38. private:
  39. Status CheckPositionNotRepeat();
  40. Status GetAippParams(const std::unique_ptr<domi::AippOpParams> &aippParams, const ge::NodePtr &aipp_node);
  41. Status CheckInputNamePositionNotRepeat();
  42. Status CheckInputRankPositionNoRepeat();
  43. Status CheckGraph(const ge::ComputeGraphPtr &graph);
  44. InsertNewOpUtil() = default;
  45. ~InsertNewOpUtil() = default;
  46. std::vector<std::unique_ptr<InsertOpBase>> insert_ops_;
  47. std::unique_ptr<domi::InsertNewOps> insert_op_conf_;
  48. void UpdateMultiBatchInputDims(const OpDescPtr &data_opdesc, Format &old_format);
  49. Status UpdatePrevNodeByAipp(NodePtr &node, std::set<NodePtr> &switchns);
  50. Status UpdateDataBySwitchN(const NodePtr &switchn, const NodePtr &data);
  51. Status GetDataRelatedNode(NodePtr &node, std::map<NodePtr, std::set<NodePtr>> &data_next_node_map);
  52. Status GetAllAipps(const NodePtr &data_node, const NodePtr &node, std::vector<NodePtr> &aipps);
  53. Status GetInputOutputInfo(NodePtr &data_node, NodePtr &aipp_node, std::string &input, std::string &output);
  54. Status SetModelInputDims(NodePtr &data_node, NodePtr &aipp_node);
  55. Status FindMaxSizeNode(const ComputeGraphPtr &graph, const NodePtr &case_node, map<uint32_t, int64_t> &max_sizes,
  56. map<uint32_t, GeTensorDescPtr> &aipp_inputs);
  57. Status UpdateCaseNode(const ComputeGraphPtr &graph, const NodePtr &case_node);
  58. };
  59. } // namespace ge
  60. #endif // GE_GRAPH_PREPROCESS_INSERT_OP_UTIL_INSERT_AIPP_OP_H_

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