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.

acl_fv.h 11 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351
  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_EXTERNAL_ACL_OPS_ACL_RETR_H_
  17. #define INC_EXTERNAL_ACL_OPS_ACL_RETR_H_
  18. #include "acl/acl.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef struct aclfvInitPara aclfvInitPara;
  23. typedef struct aclfvFeatureInfo aclfvFeatureInfo;
  24. typedef struct aclfvRepoRange aclfvRepoRange;
  25. typedef struct aclfvQueryTable aclfvQueryTable;
  26. typedef struct aclfvSearchInput aclfvSearchInput;
  27. typedef struct aclfvSearchResult aclfvSearchResult;
  28. // search operation type
  29. enum aclfvSearchType {
  30. SEARCH_1_N, // 1:N operation type
  31. SEARCH_N_M // N:M operation type
  32. };
  33. /**
  34. * @ingroup AscendCL
  35. * @brief Create fv init param.
  36. *
  37. * @param fsNum [IN] The feature num
  38. *
  39. * @retval null for failed.
  40. * @retval OtherValues success.
  41. */
  42. ACL_FUNC_VISIBILITY aclfvInitPara *aclfvCreateInitPara(uint64_t fsNum);
  43. /**
  44. * @ingroup AscendCL
  45. * @brief Destroy fv init param.
  46. *
  47. * @par Function
  48. * Can only destroy fv init param information created
  49. * through aclfvCreateInitPara interface.
  50. *
  51. * @param initPara [IN] fv init param.
  52. *
  53. * @retval ACL_SUCCESS The function is successfully executed.
  54. * @retval OtherValues Failure
  55. *
  56. * @see aclfvCreateInitPara
  57. */
  58. ACL_FUNC_VISIBILITY aclError aclfvDestroyInitPara(aclfvInitPara *initPara);
  59. /**
  60. * @ingroup AscendCL
  61. * @brief set value for maxTopNumFor1N which in fv init param.
  62. *
  63. * @param initPara [IN|OUT] fv init param.
  64. * @param maxTopNumFor1N [IN] maxTopNumFor1N value for init param.
  65. *
  66. * @retval ACL_SUCCESS The function is successfully executed.
  67. * @retval OtherValues Failure
  68. */
  69. ACL_FUNC_VISIBILITY aclError aclfvSet1NTopNum(aclfvInitPara *initPara, uint32_t maxTopNumFor1N);
  70. /**
  71. * @ingroup AscendCL
  72. * @brief set value for maxTopNumForNM which in fv init param.
  73. *
  74. * @param initPara [IN|OUT] fv init param.
  75. * @param maxTopNumForNM [IN] maxTopNumForNM value for init param.
  76. *
  77. * @retval ACL_SUCCESS The function is successfully executed.
  78. * @retval OtherValues Failure
  79. */
  80. ACL_FUNC_VISIBILITY aclError aclfvSetNMTopNum(aclfvInitPara *initPara, uint32_t maxTopNumForNM);
  81. /**
  82. * @ingroup AscendCL
  83. * @brief Create fv feature info.
  84. *
  85. * @param id0 [IN] The first level library id0
  86. * @param id1 [IN] Secondary library id1
  87. * @param offset [IN] The offset of the first feature in the library
  88. * @param featureLen [IN] Single feature length
  89. * @param featureCount [IN] Single feature count
  90. * @param featureData [IN] Feature value list
  91. * @param featureDataLen [IN] Feature value list length
  92. *
  93. * @retval null for failed.
  94. * @retval OtherValues success.
  95. */
  96. ACL_FUNC_VISIBILITY aclfvFeatureInfo *aclfvCreateFeatureInfo(uint32_t id0, uint32_t id1, uint32_t offset,
  97. uint32_t featureLen, uint32_t featureCount, uint8_t *featureData, uint32_t featureDataLen);
  98. /**
  99. * @ingroup AscendCL
  100. * @brief Destroy fv feature info.
  101. *
  102. * @par Function
  103. * Can only destroy fv feature info information created
  104. * through aclfvCreateFeatureInfo interface.
  105. *
  106. * @param featureInfo [IN] fv feature info.
  107. *
  108. * @retval ACL_SUCCESS The function is successfully executed.
  109. * @retval OtherValues Failure
  110. *
  111. * @see aclfvCreateFeatureInfo
  112. */
  113. ACL_FUNC_VISIBILITY aclError aclfvDestroyFeatureInfo(aclfvFeatureInfo *featureInfo);
  114. /**
  115. * @ingroup AscendCL
  116. * @brief Create fv repo range.
  117. *
  118. * @param id0Min [IN] id0 start value
  119. * @param id0Min [IN] id0 max
  120. * @param id1Min [IN] id0 start value
  121. * @param id1Max [IN] id1 max
  122. *
  123. * @retval null for failed. OtherValues success
  124. */
  125. ACL_FUNC_VISIBILITY aclfvRepoRange *aclfvCreateRepoRange(uint32_t id0Min, uint32_t id0Max, uint32_t id1Min,
  126. uint32_t id1Max);
  127. /**
  128. * @ingroup AscendCL
  129. * @brief Destroy fv repo range.
  130. *
  131. * @par Function
  132. * Can only destroy fv repo range information created
  133. * through aclfvCreateRepoRange interface.
  134. *
  135. * @param repoRange [IN] fv repo range.
  136. *
  137. * @retval ACL_SUCCESS The function is successfully executed.
  138. * @retval OtherValues Failure
  139. *
  140. * @see aclfvCreateRepoRange
  141. */
  142. ACL_FUNC_VISIBILITY aclError aclfvDestroyRepoRange(aclfvRepoRange *repoRange);
  143. /**
  144. * @ingroup AscendCL
  145. * @brief Create query table.
  146. *
  147. * @param queryCnt [IN] Number of tables, the maximum number is 6
  148. * @param tableLen [IN] Single table length, table length is 32KB
  149. * @param tableData [IN] Feature value list
  150. * @param tableDataLen [IN] The length of memory requested by the featureData pointer
  151. *
  152. * @retval null for failed. OtherValues success
  153. */
  154. ACL_FUNC_VISIBILITY aclfvQueryTable *aclfvCreateQueryTable(uint32_t queryCnt, uint32_t tableLen, uint8_t *tableData,
  155. uint32_t tableDataLen);
  156. /**
  157. * @ingroup AscendCL
  158. * @brief Destroy query table.
  159. *
  160. * @par Function
  161. * Can only destroy query table information created
  162. * through aclfvCreateQueryTable interface.
  163. *
  164. * @param queryTable [IN] query table.
  165. *
  166. * @retval ACL_SUCCESS The function is successfully executed.
  167. * @retval OtherValues Failure
  168. *
  169. * @see aclfvCreateQueryTable
  170. */
  171. ACL_FUNC_VISIBILITY aclError aclfvDestroyQueryTable(aclfvQueryTable *queryTable);
  172. /**
  173. * @ingroup AscendCL
  174. * @brief Create search input.
  175. *
  176. * @param queryTable [IN] query table
  177. * @param repoRange [IN] query repo range
  178. * @param topk [IN] query topk
  179. *
  180. * @retval null for failed. OtherValues success
  181. */
  182. ACL_FUNC_VISIBILITY aclfvSearchInput *aclfvCreateSearchInput(aclfvQueryTable *queryTable, aclfvRepoRange *repoRange,
  183. uint32_t topk);
  184. /**
  185. * @ingroup AscendCL
  186. * @brief Destroy search input.
  187. *
  188. * @par Function
  189. * Can only destroy search input information created
  190. * through aclfvCreateSearchInput interface.
  191. *
  192. * @param searchInput [IN] search input.
  193. *
  194. * @retval ACL_SUCCESS The function is successfully executed.
  195. * @retval OtherValues Failure
  196. *
  197. * @see aclfvCreateSearchInput
  198. */
  199. ACL_FUNC_VISIBILITY aclError aclfvDestroySearchInput(aclfvSearchInput *searchInput);
  200. /**
  201. * @ingroup AscendCL
  202. * @brief Create search result.
  203. *
  204. * @param queryCnt [IN] Retrieve the number of features
  205. * @param resultNum [IN] The number of search results for each feature, the number is queryCnt
  206. * @param resultNumDataLen [IN] resultNum memory length
  207. * @param id0 [IN] Level 1 library id0
  208. * @param id1 [IN] Secondary library id1
  209. * @param resultOffset [IN] The offset of the bottom library corresponding
  210. * to each feature retrieval result, total length topK * queryCnt
  211. * @param resultDistance [IN] Distance, total length topK * queryCnt
  212. * @param dataLen [IN] The memory size requested by
  213. * id0\id1\reslutOffset\resultDistance
  214. *
  215. * @retval null for failed. OtherValues success
  216. */
  217. ACL_FUNC_VISIBILITY aclfvSearchResult *aclfvCreateSearchResult(uint32_t queryCnt, uint32_t *resultNum,
  218. uint32_t resultNumDataLen, uint32_t *id0, uint32_t *id1, uint32_t *resultOffset, float *resultDistance,
  219. uint32_t dataLen);
  220. /**
  221. * @ingroup AscendCL
  222. * @brief Destroy search result.
  223. *
  224. * @par Function
  225. * Can only destroy search result information created
  226. * through aclfvCreateSearchResult interface.
  227. *
  228. * @param searchResult [IN] search result.
  229. *
  230. * @retval ACL_SUCCESS The function is successfully executed.
  231. * @retval OtherValues Failure
  232. *
  233. * @see aclfvCreateSearchResult
  234. */
  235. ACL_FUNC_VISIBILITY aclError aclfvDestroySearchResult(aclfvSearchResult *searchResult);
  236. /**
  237. * @ingroup AscendCL
  238. * @brief fv IP initialize.
  239. *
  240. * @param initPara [IN] fv init param.
  241. *
  242. * @retval ACL_SUCCESS The function is successfully executed.
  243. * @retval OtherValues Failure.
  244. */
  245. ACL_FUNC_VISIBILITY aclError aclfvInit(aclfvInitPara *initPara);
  246. /**
  247. * @ingroup AscendCL
  248. * @brief release fv resources.
  249. *
  250. * @par Function
  251. * Can only release fv resources created
  252. * through aclfvInit interface.
  253. *
  254. * @retval ACL_SUCCESS The function is successfully executed.
  255. * @retval OtherValues Failure.
  256. *
  257. * @see aclfvInit
  258. */
  259. ACL_FUNC_VISIBILITY aclError aclfvRelease();
  260. /**
  261. * @ingroup AscendCL
  262. * @brief fv repo add.
  263. *
  264. * @param type [IN] repo add type
  265. * @param featureInfo [IN] add feature information
  266. * @param stream [IN] stream of task execute
  267. *
  268. * @retval ACL_SUCCESS The function is successfully executed.
  269. * @retval OtherValues Failure.
  270. */
  271. ACL_FUNC_VISIBILITY aclError aclfvRepoAdd(aclfvSearchType type, aclfvFeatureInfo *featureInfo, aclrtStream stream);
  272. /**
  273. * @ingroup AscendCL
  274. * @brief fv repo del.
  275. *
  276. * @param type [IN] repo delete type
  277. * @param repoRange [IN] repo range information
  278. * @param stream [IN] stream of task execute
  279. *
  280. * @retval ACL_SUCCESS The function is successfully executed.
  281. * @retval OtherValues Failure.
  282. */
  283. ACL_FUNC_VISIBILITY aclError aclfvRepoDel(aclfvSearchType type, aclfvRepoRange *repoRange, aclrtStream stream);
  284. /**
  285. * @ingroup AscendCL
  286. * @brief fv accurate del.
  287. *
  288. * @param featureInfo [IN] accurate delete feature information
  289. * @param stream [IN] stream of task execute
  290. *
  291. * @retval ACL_SUCCESS The function is successfully executed.
  292. * @retval OtherValues Failure.
  293. */
  294. ACL_FUNC_VISIBILITY aclError aclfvDel(aclfvFeatureInfo *featureInfo, aclrtStream stream);
  295. /**
  296. * @ingroup AscendCL
  297. * @brief fv accurate modify.
  298. *
  299. * @param featureInfo [IN] accurate modify feature information
  300. * @param stream [IN] stream of task execute
  301. *
  302. * @retval ACL_SUCCESS The function is successfully executed.
  303. * @retval OtherValues Failure.
  304. */
  305. ACL_FUNC_VISIBILITY aclError aclfvModify(aclfvFeatureInfo *featureInfo, aclrtStream stream);
  306. /**
  307. * @ingroup AscendCL
  308. * @brief fv search.
  309. *
  310. * @param type [IN] search type
  311. * @param searchInput [IN] search input
  312. * @param searchRst [OUT] search result
  313. * @param stream [IN] stream of task execute
  314. *
  315. * @retval ACL_SUCCESS The function is successfully executed.
  316. * @retval OtherValues Failure.
  317. */
  318. ACL_FUNC_VISIBILITY aclError aclfvSearch(aclfvSearchType type, aclfvSearchInput *searchInput,
  319. aclfvSearchResult *searchRst, aclrtStream stream);
  320. #ifdef __cplusplus
  321. }
  322. #endif
  323. #endif // INC_EXTERNAL_ACL_OPS_ACL_RETR_H_

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