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.

generator_api.h 6.8 kB

5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
4 years ago
5 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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 INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_
  17. #define INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_
  18. #if defined(_MSC_VER)
  19. #ifdef FUNC_VISIBILITY
  20. #define GE_FUNC_VISIBILITY _declspec(dllexport)
  21. #else
  22. #define GE_FUNC_VISIBILITY
  23. #endif
  24. #else
  25. #ifdef FUNC_VISIBILITY
  26. #define GE_FUNC_VISIBILITY __attribute__((visibility("default")))
  27. #else
  28. #define GE_FUNC_VISIBILITY
  29. #endif
  30. #endif
  31. #include <stdint.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. typedef uint32_t Status_t;
  36. typedef void *OpAttr_t;
  37. typedef void *OpTensor_t;
  38. ///
  39. /// @ingroup ge
  40. /// @brief Generate offline model for the op.
  41. /// @param [in] op_type: type name of the op.
  42. /// @param [in] in_tensor: input description array (created by OpTensorCreate).
  43. /// @param [in] in_num: number of in_tensor.
  44. /// @param [in] out_tensor: output description array (created by OpTensorCreate).
  45. /// @param [in] out_num: number of out_tensor.
  46. /// @param [in] attr: the attributes of the op (created by OpAttrCreate).
  47. /// @param [in] om_file: file name for the om to save.
  48. /// @return 0 for success / others for fail
  49. ///
  50. GE_FUNC_VISIBILITY extern Status_t OpTaskGernerator(const char *op_type, const OpTensor_t *in_tensor, int in_num,
  51. const OpTensor_t *out_tensor, int out_num, const OpAttr_t attr,
  52. const char *om_file);
  53. ///
  54. /// @ingroup ge
  55. /// @brief Create Tensor Description.
  56. /// @param [in] format: tensor format of the data.
  57. /// @param [in] datatype: tensor type of the data.
  58. /// @param [in] shape: tensor shape array.
  59. /// @param [in] num: number of shape.
  60. /// @return OpTensor_t for success / nullptr for failure
  61. ///
  62. GE_FUNC_VISIBILITY extern OpTensor_t OpTensorCreate(int format, int datatype, const int64_t *shape, int num);
  63. ///
  64. /// @ingroup ge
  65. /// @brief Destroy Tensor Description.
  66. /// @param [in] OpTensor_t tensor: created by OpTensorCreate.
  67. /// @param [out] none
  68. /// @return 0 for success / others for failure.
  69. ///
  70. GE_FUNC_VISIBILITY extern Status_t OpTensorDestroy(OpTensor_t tensor);
  71. ///
  72. /// @ingroup ge
  73. /// @brief Create an attribute holder.
  74. /// @param [in] none
  75. /// @param [out] none
  76. /// @return OpAttr_t for success / nullptr for failure.
  77. ///
  78. GE_FUNC_VISIBILITY extern OpAttr_t OpAttrCreate();
  79. ///
  80. /// @ingroup ge
  81. /// @brief Destroy Attribute holder.
  82. /// @param [in] OpAttr_t attr: created by OpAttrCreate.
  83. /// @param [out] none
  84. /// @return 0 for success / others for failure.
  85. ///
  86. GE_FUNC_VISIBILITY extern Status_t OpAttrDestroy(OpAttr_t attr);
  87. ///
  88. /// @ingroup ge
  89. /// @brief Set a boolean attribute to the attribute holder.
  90. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  91. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  92. /// @param [in] value: attributed value.
  93. /// @return 0 for success / others for failure.
  94. ///
  95. GE_FUNC_VISIBILITY extern Status_t SetAttrBool(OpAttr_t attr, const char *name, bool value);
  96. ///
  97. /// @ingroup ge
  98. /// @brief Set an integer attribute to the attribute holder.
  99. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  100. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  101. /// @param [in] value: attribute value.
  102. /// @return 0 for success / others for failure.
  103. ///
  104. GE_FUNC_VISIBILITY extern Status_t SetAttrInt(OpAttr_t attr, const char *name, int64_t value);
  105. ///
  106. /// @ingroup ge
  107. /// @brief Set a float attribute to the attribute holder.
  108. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  109. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  110. /// @param [in] value: attribute value.
  111. /// @return 0 for success / others for failure.
  112. ///
  113. GE_FUNC_VISIBILITY extern Status_t SetAttrFloat(OpAttr_t attr, const char *name, float value);
  114. ///
  115. /// @ingroup ge
  116. /// @brief Set a string attribute to the attribute holder.
  117. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  118. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  119. /// @param [in] value: attribute value (can`t be nullptr, end with '\0').
  120. /// @return 0 for success / others for failure.
  121. ///
  122. GE_FUNC_VISIBILITY extern Status_t SetAttrString(OpAttr_t attr, const char *name, const char *value);
  123. ///
  124. /// @ingroup ge
  125. /// @brief Set a boolean array attribute to the attribute holder.
  126. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  127. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  128. /// @param [in] value: attribute value array.
  129. /// @param [in] num: number of value array.
  130. /// @return 0 for success / others for failure.
  131. ///
  132. GE_FUNC_VISIBILITY extern Status_t SetAttrBoolList(OpAttr_t attr, const char *name, const bool *value, int num);
  133. ///
  134. /// @ingroup ge
  135. /// @brief Set an integer array attribute to the attribute holder.
  136. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  137. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  138. /// @param [in] value: attribute value array.
  139. /// @param [in] num: number of value array.
  140. /// @return 0 for success / others for failure.
  141. ///
  142. GE_FUNC_VISIBILITY extern Status_t SetAttrIntList(OpAttr_t attr, const char *name, const int64_t *value, int num);
  143. ///
  144. /// @ingroup ge
  145. /// @brief Set a float array attribute to the attribute holder.
  146. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  147. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  148. /// @param [in] value: attribute value array.
  149. /// @param [in] num: number of value array.
  150. /// @return 0 for success / others for failure.
  151. ///
  152. GE_FUNC_VISIBILITY extern Status_t SetAttrFloatList(OpAttr_t attr, const char *name, const float *value, int num);
  153. ///
  154. /// @ingroup ge
  155. /// @brief Set a string array attribute to the attribute holder.
  156. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  157. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  158. /// @param [in] value: attribute value array (each value can`t be nullptr, end with '\0').
  159. /// @param [in] num: number of value array.
  160. /// @return 0 for success / others for failure.
  161. ///
  162. GE_FUNC_VISIBILITY extern Status_t SetAttrStringList(OpAttr_t attr, const char *name, const char **value, int num);
  163. #ifdef __cplusplus
  164. }
  165. #endif
  166. #endif // INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_

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