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

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

Contributors (1)