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.

input_output_connection_identify_pass.h 3.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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_PASSES_INPUT_OUTPUT_CONNECTION_IDENTIFY_PASS_H_
  17. #define GE_GRAPH_PASSES_INPUT_OUTPUT_CONNECTION_IDENTIFY_PASS_H_
  18. #include <map>
  19. #include <vector>
  20. #include "graph/graph.h"
  21. #include "inc/graph_pass.h"
  22. namespace ge {
  23. class InputOutputConnectionIdentifyPass : public GraphPass {
  24. public:
  25. Status Run(ComputeGraphPtr graph) override;
  26. private:
  27. ///
  28. /// Find all nodes that connect to input node.
  29. /// @param [in] input node
  30. /// @param [out] map of nodes and anchor index that connect to input
  31. /// @param [out] map of nodes and anchor index that connect to output
  32. /// @return Status
  33. ///
  34. Status ProcessInputNode(const NodePtr &node, std::map<NodePtr, std::vector<uint32_t>> &connect_input_node_idx,
  35. std::map<NodePtr, std::vector<uint32_t>> &connect_output_node_idx);
  36. ///
  37. /// Find all nodes that connect to output node.
  38. /// @param [in] output node
  39. /// @param [out] map of nodes and anchor index that connect to input
  40. /// @param [out] map of nodes and anchor index that connect to output
  41. /// @return Status
  42. ///
  43. Status ProcessOutputNode(const NodePtr &node, std::map<NodePtr, std::vector<uint32_t>> &connect_input_node_idx,
  44. std::map<NodePtr, std::vector<uint32_t>> &connect_output_node_idx);
  45. ///
  46. /// Update all nodes that have shared memory.
  47. /// @param [in] symbol string
  48. /// @param [out] map of nodes and anchor index that connect to input
  49. /// @param [out] map of nodes and anchor index that connect to output
  50. /// @return Status
  51. ///
  52. Status UpdateNodeIdxMap(const string &symbol_string, std::map<NodePtr, std::vector<uint32_t>> &connect_input_node_idx,
  53. std::map<NodePtr, std::vector<uint32_t>> &connect_output_node_idx);
  54. ///
  55. /// Set attr for all nodes that connect to input and output.
  56. /// @param [in] map of nodes and anchor index that connect to input
  57. /// @param [in] map of nodes and anchor index that connect to output
  58. /// @return Status
  59. ///
  60. Status SetNodeAttrOfConnectingInputOutput(const std::map<NodePtr, std::vector<uint32_t>> &connect_input_node_idx,
  61. const std::map<NodePtr, std::vector<uint32_t>> &connect_output_node_idx);
  62. // Members for ref mapping
  63. std::map<std::string, std::list<NodeIndexIO>> symbol_to_anchors_;
  64. std::map<std::string, std::string> anchor_to_symbol_;
  65. };
  66. } // namespace ge
  67. #endif // GE_GRAPH_PASSES_INPUT_OUTPUT_CONNECTION_IDENTIFY_PASS_H_

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