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

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