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.

fwk_adpt_struct.h 5.0 kB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 FWK_ADPT_STRUCT_H__
  17. #define FWK_ADPT_STRUCT_H__
  18. #include <cstdint>
  19. namespace aicpu {
  20. namespace FWKAdapter {
  21. using char_t = char;
  22. // API RETURN CODE
  23. enum FWKAdptAPIRetCode {
  24. FWK_ADPT_SUCCESS = 0, // success
  25. FWK_ADPT_NOT_INIT = 1, // not init
  26. FWK_ADPT_ALLOC_FAILED = 2, // allocate memory failed
  27. FWK_ADPT_PARAM_INVALID = 3, // invalid input param
  28. FWK_ADPT_PARAM_PARSE_FAILED = 4, // parase input param failed
  29. FWK_ADPT_NATIVE_ERROR = 5, // error code
  30. FWK_ADPT_NOT_SUPPORT_OPTYPE = 6, // unsupport operate type
  31. FWK_ADPT_INTERNAL_ERROR = 7, // adpter internal error
  32. FWK_ADPT_NOT_SUPPORT_DATATYPE = 8, // unsupport input/output data type
  33. FWK_ADPT_KERNEL_ALREADY_RUNING = 9, // kernel already runing, not support parallel run
  34. FWK_ADPT_SESSION_NOT_EXIST = 10, // session id not exist
  35. FWK_ADPT_SESSION_ALREADY_EXIST = 11, // session id alread exist for create session
  36. FWK_ADPT_NATIVE_END_OF_SEQUENCE = 12, // end of sequence
  37. FWK_ADPT_EXTEND_TYPE_NOT_EXIST = 13, // extend info type not exist
  38. FWK_ADPT_UNKNOWN_ERROR = 99 // unknown error code
  39. };
  40. // FWKAdapter operate type
  41. // Notice: add new operate type need check with OMM, and make sure append to the end line.
  42. enum FWKOperateType {
  43. FWK_ADPT_SESSION_CREATE = 0,
  44. FWK_ADPT_KERNEL_RUN,
  45. FWK_ADPT_KERNEL_DESTROY,
  46. FWK_ADPT_SESSION_DESTROY,
  47. FWK_ADPT_SINGLE_OP_RUN,
  48. FWK_ADPT_KERNEL_RUN_NO_SESS,
  49. };
  50. // Extend Info type for task
  51. enum FWKTaskExtInfoType {
  52. FWK_ADPT_EXT_SHAPE_TYPE = 0,
  53. FWK_ADPT_EXT_INPUT_SHAPE,
  54. FWK_ADPT_EXT_OUTPUT_SHAPE,
  55. FWK_ADPT_EXT_UPDATE_ADDR,
  56. FWK_ADPT_EXT_OP_NAME,
  57. FWK_ADPT_EXT_SESSION_INFO,
  58. FWK_ADPT_EXT_BITMAP,
  59. FWK_ADPT_EXT_TOPIC_TYPE,
  60. FWK_ADPT_EXT_ASYNCWAIT,
  61. FWK_ADPT_EXT_UNKNOWN_SHAPE_INPUT_INDEX,
  62. FWK_ADPT_EXT_UNKNOWN_SHAPE_OUTPUT_INDEX,
  63. FWK_ADPT_EXT_INVALID
  64. };
  65. enum FWKExtTopicType {
  66. FWK_ADPT_TOPIC_DEVICE_ONLY = 0,
  67. FWK_ADPT_TOPIC_DEVICE_FIRST,
  68. FWK_ADPT_TOPIC_HOST_ONLY,
  69. FWK_ADPT_TOPIC_HOST_FIRST,
  70. FWK_ADPT_TOPIC_INVALID
  71. };
  72. enum FWKExtUpdateAddrType {
  73. FWK_ADPT_UPDATE_NULL = 0,
  74. FWK_ADPT_UPDATE_INPUT,
  75. FWK_ADPT_UPDATE_OUTPUT,
  76. FWK_ADPT_UPDATE_INPUT_OUTPUT
  77. };
  78. enum FWKExtWaitType {
  79. FWK_ADPT_WAIT_TYPE_NULL = 0,
  80. FWK_ADPT_WAIT_TYPE_EVENT,
  81. FWK_ADPT_WAIT_TYPE_INVALID
  82. };
  83. #pragma pack(push, 1)
  84. // API Parameter Structure
  85. struct StrFWKKernel {
  86. FWKOperateType opType;
  87. uint64_t sessionID; // unique
  88. uint64_t stepIDAddr; // step id addr
  89. uint64_t kernelID; // run kernel id, unique in session
  90. uint64_t nodeDefLen; // nodeDef protobuf len
  91. uint64_t nodeDefBuf; // NodeDef protobuf offset addr, need convert to void*
  92. uint64_t funDefLibLen; // FunctionDefLibrary protobuf len
  93. uint64_t funDefLibBuf; // FunctionDefLibrary protobuf addr which use in NodeDef, need convert to void*
  94. uint64_t inputOutputLen; // InputOutput shap protobuf len
  95. uint64_t inputOutputBuf; // InputOutput shap protobuf addr, need convert to void*
  96. uint64_t workspaceBaseAddr; // Workspace base addr, need convert to void*
  97. uint64_t inputOutputAddr; // InputOutput addr, need convert to void*
  98. uint64_t extInfoLen; // extend info total length
  99. uint64_t extInfoAddr; // extend info addr, ExtInfo structure
  100. };
  101. #pragma pack(pop)
  102. typedef StrFWKKernel FWKOperateParam;
  103. // Extent info ShapeAndType
  104. const uint32_t kMaxShapeDims = 8U;
  105. #pragma pack(push, 1)
  106. struct ShapeAndType {
  107. int32_t type;
  108. int64_t dims[kMaxShapeDims];
  109. };
  110. #pragma pack(pop)
  111. // Extend info structure for extInfoAddr
  112. const uint32_t kExtInfoHeadSize = 8U;
  113. #pragma pack(push, 1)
  114. struct ExtInfo {
  115. int32_t infoType; // extend type
  116. uint32_t infoLen; // length for infoMsg
  117. char_t infoMsg[0]; // extend value
  118. };
  119. #pragma pack(pop)
  120. #pragma pack(push, 1)
  121. struct ResultSummary {
  122. uint64_t shape_data_ptr; // shape data addr, need convert to void*
  123. uint64_t shape_data_size; // num of dims
  124. uint64_t raw_data_ptr; // raw data addr, need convert to void*
  125. uint64_t raw_data_size; // size of raw data
  126. };
  127. #pragma pack(pop)
  128. #pragma pack(push, 1)
  129. struct AsyncWait {
  130. uint8_t waitType; // wait type, FWK_ADPT_WAIT_TYPE_EVENT: event wait
  131. uint32_t waitId; // wait id, GE refresh
  132. uint32_t timeOut; // reserved
  133. uint64_t reserved;
  134. };
  135. #pragma pack(pop)
  136. } // end namespace FWKAdapter
  137. } // namespace aicpu
  138. #endif // FWK_ADPT_STRUCT_H__

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