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.

omg_util.h 3.4 kB

5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /**
  2. * Copyright 2019-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_COMMON_OMG_UTIL_H_
  17. #define GE_GRAPH_COMMON_OMG_UTIL_H_
  18. #include <map>
  19. #include <string>
  20. #include <utility>
  21. #include <vector>
  22. #include "framework/common/types.h"
  23. #include "framework/common/util.h"
  24. #include "graph/node.h"
  25. namespace ge {
  26. static constexpr int64_t kBufferPoolMemAlignSize = 512;
  27. static constexpr uint32_t kBufferPoolNodeOutIndex = 0;
  28. static constexpr uint32_t kEventReuseThreshold = 65500;
  29. ///
  30. /// @brief get the Original Type of FrameworkOp
  31. /// @param [in] node
  32. /// @param [out] type
  33. /// @return Status
  34. ///
  35. Status GetOriginalType(const ge::NodePtr &node, string &type);
  36. ///
  37. /// @brief set op stream_label
  38. /// @param [in] node
  39. /// @param [in] label
  40. /// @return Status
  41. ///
  42. Status SetStreamLabel(const ge::NodePtr &node, const std::string &label);
  43. ///
  44. /// @brief set op cycle_event flag
  45. /// @param [in] node
  46. /// @return Status
  47. ///
  48. Status SetCycleEvent(const ge::NodePtr &node);
  49. ///
  50. /// @brief set op active_label_list
  51. /// @param [in] node
  52. /// @param [in] label
  53. /// @return Status
  54. ///
  55. Status SetActiveLabelList(const ge::NodePtr &node, const std::vector<std::string> &active_label_list);
  56. ///
  57. /// @brief set op branch_label
  58. /// @param [in] node
  59. /// @param [in] branch_label
  60. /// @return Status
  61. ///
  62. Status SetSwitchBranchNodeLabel(const ge::NodePtr &node, const std::string &branch_label);
  63. ///
  64. /// @brief set op true_branch flag
  65. /// @param [in] node
  66. /// @param [in] value
  67. /// @return Status
  68. ///
  69. Status SetSwitchTrueBranchFlag(const ge::NodePtr &node, bool value);
  70. ///
  71. /// @brief set op original name
  72. /// @param [in] node
  73. /// @param [in] orig_name
  74. /// @return Status
  75. ///
  76. Status SetOriginalNodeName(const ge::NodePtr &node, const std::string &orig_name);
  77. ///
  78. /// @brief set op cyclic_dependence flag
  79. /// @param [in] node
  80. /// @return Status
  81. ///
  82. Status SetCyclicDependenceFlag(const ge::NodePtr &node);
  83. ///
  84. /// @brief set op next_iteration name
  85. /// @param [in] Merge Node
  86. /// @param [in] NextIteration Node
  87. /// @return Status
  88. ///
  89. Status SetNextIteration(const NodePtr &node, const NodePtr &next);
  90. ///
  91. /// @brief Align the memory
  92. /// @param [in/out] memory size
  93. /// @param [in] alinment
  94. /// @return void
  95. ///
  96. void AlignMemSize(int64_t &mem_size, int64_t align_size);
  97. ///
  98. /// @brief Get memory size from tensor desc
  99. /// @param [in] node
  100. /// @param [out] memory size
  101. /// @return Status
  102. ///
  103. Status GetMemorySize(const NodePtr &node, int64_t &output_size);
  104. ///
  105. /// @brief Check Is Unknown shape Tensor
  106. /// @param [in] tensor_desc
  107. /// @return true: Unknown / false: Known
  108. ///
  109. bool IsUnknownShapeTensor(const GeTensorDesc &tensor_desc);
  110. ///
  111. /// @brief Set Op _control_flow_group flag
  112. /// @param [in] node
  113. /// @param [in] group, condition group index of node.
  114. /// @return
  115. ///
  116. void SetControlFlowGroup(const NodePtr &node, int64_t group);
  117. } // namespace ge
  118. #endif // GE_GRAPH_COMMON_OMG_UTIL_H_

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