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.

unused_args_clean_pass.h 2.9 kB

4 years ago
4 years ago
4 years ago
4 years ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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_COMMON_CASE_ARGS_CLEAN_H_
  17. #define GE_COMMON_CASE_ARGS_CLEAN_H_
  18. #include "graph/types.h"
  19. #include "inc/graph_pass.h"
  20. #include <map>
  21. #include <set>
  22. #include <vector>
  23. #include <string>
  24. using std::set;
  25. using std::map;
  26. namespace ge {
  27. class UnusedArgsCleanPass : public GraphPass {
  28. public:
  29. Status Run(ComputeGraphPtr graph) override;
  30. private:
  31. ///
  32. /// @ingroup ge
  33. /// @brief Create nodes for root graph.
  34. /// @param [in] graph_nodes: Data groups of subgraph.
  35. /// @param [in] func_node: functional Node of Case.
  36. /// @param [in] parent_index: parent index for check.
  37. /// @return true: unused / false: used
  38. ///
  39. bool UnusedInputTensor(const map<ComputeGraphPtr, map<uint32_t, NodePtr>> &graph_nodes,
  40. const NodePtr &func_node, uint32_t parent_index);
  41. ///
  42. /// @ingroup ge
  43. /// @brief Get all Data nodes for all subgraph.
  44. /// @param [in] graph: Root compute graph.
  45. /// @param [in] func_desc: functional OpDesc of Case.
  46. /// @param [out] graph_nodes: Data groups of subgraph.
  47. /// @return 0: SUCCESS / others: FAILED
  48. ///
  49. Status ClassifyDataNodes(const ComputeGraphPtr &graph, const OpDescPtr &func_desc,
  50. map<ComputeGraphPtr, map<uint32_t, NodePtr>> &graph_nodes);
  51. ///
  52. /// @ingroup ge
  53. /// @brief Remove Case input Tensor.
  54. /// @param [in] graph_nodes: Data groups of subgraph.
  55. /// @param [in] func_node: functional Node of Case.
  56. /// @param [in] parent_index: parent index for remove.
  57. /// @return 0: SUCCESS / others: FAILED
  58. ///
  59. Status RemoveInputTensor(const map<ComputeGraphPtr, map<uint32_t, NodePtr>> &graph_nodes,
  60. const NodePtr &func_node, uint32_t parent_index);
  61. ///
  62. /// @ingroup ge
  63. /// @brief Update Case input Tensor.
  64. /// @param [in] graph_nodes: Data groups of subgraph.
  65. /// @param [in] func_node: functional Node of Case.
  66. /// @param [in] parent_index: parent index for update.
  67. /// @param [in] unused_num: unused args num.
  68. /// @return 0: SUCCESS / others: FAILED
  69. ///
  70. Status UpdateInputTensor(const map<ComputeGraphPtr, map<uint32_t, NodePtr>> &graph_nodes,
  71. const NodePtr &func_node, uint32_t parent_index, uint32_t unused_num);
  72. };
  73. } // namespace ge
  74. #endif // GE_COMMON_CASE_ARGS_CLEAN_H_

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