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.2 kB

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

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

Contributors (1)