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.

transop_symmetry_elimination_pass.h 2.9 kB

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_SYMMETRY_ELIMINATION_PASS_H
  17. #define GE_SYMMETRY_ELIMINATION_PASS_H
  18. #include "graph/passes/base_pass.h"
  19. namespace ge {
  20. class TransOpSymmetryEliminationPass : public BaseNodePass {
  21. public:
  22. Status Run(NodePtr &node) override;
  23. private:
  24. ///
  25. /// Judge whether the node can be offset
  26. /// 1.both are transform op
  27. /// 2.is symmetry position
  28. /// 3.satisfy precision loss
  29. /// @param node
  30. /// @return True or False
  31. ///
  32. static bool CheckCanBeEliminated(const ge::NodePtr &src_node, const InDataAnchorPtr &dst_in_anchor);
  33. ///
  34. /// two transform nodes can be offset only when the front node's input is
  35. /// consistent with the back one's output
  36. /// @param src_node: the front node
  37. /// @param dst_node: the back node
  38. /// @return True or False, whether can be offset or not
  39. ///
  40. static bool DescAreSymmetry(const NodePtr &src_node, const NodePtr &dst_node);
  41. ///
  42. /// get the number of unknown shape of node
  43. /// @param node_desc: node to be checked
  44. /// @return 0 , is not dynamic shape; UNKNOWN_DIM_NUM , all dims are unknown; n , n > 0 , has n dims unknown
  45. ///
  46. static int GetUnknownDimsNum(const GeTensorDesc& node_desc);
  47. ///
  48. /// judge after two transposed op transform the raw data will be the same
  49. /// @param src_node: first transposed op
  50. /// @param dst_node: second transposed op
  51. /// @return True or False, same or not
  52. ///
  53. static bool JudgeTransposeDBack2Raw(const NodePtr &src_node, const NodePtr &dst_node);
  54. ///
  55. /// two transform nodes can be offset like A->T1->T2->B
  56. /// 1.unlink T1->T2
  57. /// 2.link A->T2
  58. /// 3.copy in-control/data-in-control from T1->T2
  59. /// 4.isolateAndDelete T2, it will re-pass all in and out node
  60. /// then we get A->B . Leave T1 to prune pass.
  61. /// ->T1
  62. /// @param src_node: the front node
  63. /// @param src_out_anchor: the front node out anchor
  64. /// @param dst_node: the back node
  65. /// @param dst_in_anchor: the back node in anchor
  66. /// @return SUCCESS or Fail, whether
  67. ///
  68. Status EliminateTransOp(NodePtr &src_node, const OutDataAnchorPtr &src_out_anchor, NodePtr &dst_node,
  69. const InDataAnchorPtr &dst_in_anchor);
  70. Status RemoveTransOpWithoutOutput(NodePtr &pre_node, NodePtr &trans_node);
  71. };
  72. } // namespace ge
  73. #endif // GE_SYMMETRY_ELIMINATION_PASS_H

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