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
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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, const char *om_file);
  52. ///
  53. /// @ingroup ge
  54. /// @brief Create Tensor Description.
  55. /// @param [in] format: tensor format of the data.
  56. /// @param [in] datatype: tensor type of the data.
  57. /// @param [in] shape: tensor shape array.
  58. /// @param [in] num: number of shape.
  59. /// @return OpTensor_t for success / nullptr for failure
  60. ///
  61. GE_FUNC_VISIBILITY extern OpTensor_t OpTensorCreate(int format, int datatype, const int64_t *shape, int num);
  62. ///
  63. /// @ingroup ge
  64. /// @brief Destroy Tensor Description.
  65. /// @param [in] OpTensor_t tensor: created by OpTensorCreate.
  66. /// @param [out] none
  67. /// @return 0 for success / others for failure.
  68. ///
  69. GE_FUNC_VISIBILITY extern Status_t OpTensorDestroy(OpTensor_t tensor);
  70. ///
  71. /// @ingroup ge
  72. /// @brief Create an attribute holder.
  73. /// @param [in] none
  74. /// @param [out] none
  75. /// @return OpAttr_t for success / nullptr for failure.
  76. ///
  77. GE_FUNC_VISIBILITY extern OpAttr_t OpAttrCreate();
  78. ///
  79. /// @ingroup ge
  80. /// @brief Destroy Attribute holder.
  81. /// @param [in] OpAttr_t attr: created by OpAttrCreate.
  82. /// @param [out] none
  83. /// @return 0 for success / others for failure.
  84. ///
  85. GE_FUNC_VISIBILITY extern Status_t OpAttrDestroy(OpAttr_t attr);
  86. ///
  87. /// @ingroup ge
  88. /// @brief Set a boolean attribute to the attribute holder.
  89. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  90. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  91. /// @param [in] value: attributed value.
  92. /// @return 0 for success / others for failure.
  93. ///
  94. GE_FUNC_VISIBILITY extern Status_t SetAttrBool(OpAttr_t attr, const char *name, bool value);
  95. ///
  96. /// @ingroup ge
  97. /// @brief Set an integer attribute to the attribute holder.
  98. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  99. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  100. /// @param [in] value: attribute value.
  101. /// @return 0 for success / others for failure.
  102. ///
  103. GE_FUNC_VISIBILITY extern Status_t SetAttrInt(OpAttr_t attr, const char *name, int64_t value);
  104. ///
  105. /// @ingroup ge
  106. /// @brief Set a float attribute to the attribute holder.
  107. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  108. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  109. /// @param [in] value: attribute value.
  110. /// @return 0 for success / others for failure.
  111. ///
  112. GE_FUNC_VISIBILITY extern Status_t SetAttrFloat(OpAttr_t attr, const char *name, float value);
  113. ///
  114. /// @ingroup ge
  115. /// @brief Set a string attribute to the attribute holder.
  116. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  117. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  118. /// @param [in] value: attribute value (can`t be nullptr, end with '\0').
  119. /// @return 0 for success / others for failure.
  120. ///
  121. GE_FUNC_VISIBILITY extern Status_t SetAttrString(OpAttr_t attr, const char *name, const char *value);
  122. ///
  123. /// @ingroup ge
  124. /// @brief Set a boolean array attribute to the attribute holder.
  125. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  126. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  127. /// @param [in] value: attribute value array.
  128. /// @param [in] num: number of value array.
  129. /// @return 0 for success / others for failure.
  130. ///
  131. GE_FUNC_VISIBILITY extern Status_t SetAttrBoolList(OpAttr_t attr, const char *name, const bool *value, int num);
  132. ///
  133. /// @ingroup ge
  134. /// @brief Set an integer array attribute to the attribute holder.
  135. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  136. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  137. /// @param [in] value: attribute value array.
  138. /// @param [in] num: number of value array.
  139. /// @return 0 for success / others for failure.
  140. ///
  141. GE_FUNC_VISIBILITY extern Status_t SetAttrIntList(OpAttr_t attr, const char *name, const int64_t *value, int num);
  142. ///
  143. /// @ingroup ge
  144. /// @brief Set a float array attribute to the attribute holder.
  145. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  146. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  147. /// @param [in] value: attribute value array.
  148. /// @param [in] num: number of value array.
  149. /// @return 0 for success / others for failure.
  150. ///
  151. GE_FUNC_VISIBILITY extern Status_t SetAttrFloatList(OpAttr_t attr, const char *name, const float *value, int num);
  152. ///
  153. /// @ingroup ge
  154. /// @brief Set a string array attribute to the attribute holder.
  155. /// @param [in] attr: attribute holder (created by OpAttrCreate).
  156. /// @param [in] name: attribute name (can`t be nullptr, end with '\0').
  157. /// @param [in] value: attribute value array (each value can`t be nullptr, end with '\0').
  158. /// @param [in] num: number of value array.
  159. /// @return 0 for success / others for failure.
  160. ///
  161. GE_FUNC_VISIBILITY extern Status_t SetAttrStringList(OpAttr_t attr, const char *name, const char **value, int num);
  162. #ifdef __cplusplus
  163. }
  164. #endif
  165. #endif // INC_FRAMEWORK_GENERATOR_GENERATOR_API_H_

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