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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  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,
  98. uint8_t *featureData, uint32_t featureDataLen);
  99. /**
  100. * @ingroup AscendCL
  101. * @brief Destroy fv feature info.
  102. *
  103. * @par Function
  104. * Can only destroy fv feature info information created
  105. * through aclfvCreateFeatureInfo interface.
  106. *
  107. * @param featureInfo [IN] fv feature info.
  108. *
  109. * @retval ACL_SUCCESS The function is successfully executed.
  110. * @retval OtherValues Failure
  111. *
  112. * @see aclfvCreateFeatureInfo
  113. */
  114. ACL_FUNC_VISIBILITY aclError aclfvDestroyFeatureInfo(aclfvFeatureInfo *featureInfo);
  115. /**
  116. * @ingroup AscendCL
  117. * @brief Create fv repo range.
  118. *
  119. * @param id0Min [IN] id0 start value
  120. * @param id0Min [IN] id0 max
  121. * @param id1Min [IN] id0 start value
  122. * @param id1Max [IN] id1 max
  123. *
  124. * @retval null for failed. OtherValues success
  125. */
  126. ACL_FUNC_VISIBILITY aclfvRepoRange *aclfvCreateRepoRange(uint32_t id0Min, uint32_t id0Max, uint32_t id1Min,
  127. uint32_t id1Max);
  128. /**
  129. * @ingroup AscendCL
  130. * @brief Destroy fv repo range.
  131. *
  132. * @par Function
  133. * Can only destroy fv repo range information created
  134. * through aclfvCreateRepoRange interface.
  135. *
  136. * @param repoRange [IN] fv repo range.
  137. *
  138. * @retval ACL_SUCCESS The function is successfully executed.
  139. * @retval OtherValues Failure
  140. *
  141. * @see aclfvCreateRepoRange
  142. */
  143. ACL_FUNC_VISIBILITY aclError aclfvDestroyRepoRange(aclfvRepoRange *repoRange);
  144. /**
  145. * @ingroup AscendCL
  146. * @brief Create query table.
  147. *
  148. * @param queryCnt [IN] Number of tables, the maximum number is 6
  149. * @param tableLen [IN] Single table length, table length is 32KB
  150. * @param tableData [IN] Feature value list
  151. * @param tableDataLen [IN] The length of memory requested by the featureData pointer
  152. *
  153. * @retval null for failed. OtherValues success
  154. */
  155. ACL_FUNC_VISIBILITY aclfvQueryTable *aclfvCreateQueryTable(uint32_t queryCnt, uint32_t tableLen, uint8_t *tableData,
  156. uint32_t tableDataLen);
  157. /**
  158. * @ingroup AscendCL
  159. * @brief Destroy query table.
  160. *
  161. * @par Function
  162. * Can only destroy query table information created
  163. * through aclfvCreateQueryTable interface.
  164. *
  165. * @param queryTable [IN] query table.
  166. *
  167. * @retval ACL_SUCCESS The function is successfully executed.
  168. * @retval OtherValues Failure
  169. *
  170. * @see aclfvCreateQueryTable
  171. */
  172. ACL_FUNC_VISIBILITY aclError aclfvDestroyQueryTable(aclfvQueryTable *queryTable);
  173. /**
  174. * @ingroup AscendCL
  175. * @brief Create search input.
  176. *
  177. * @param queryTable [IN] query table
  178. * @param repoRange [IN] query repo range
  179. * @param topk [IN] query topk
  180. *
  181. * @retval null for failed. OtherValues success
  182. */
  183. ACL_FUNC_VISIBILITY aclfvSearchInput *aclfvCreateSearchInput(aclfvQueryTable *queryTable, aclfvRepoRange *repoRange,
  184. uint32_t topk);
  185. /**
  186. * @ingroup AscendCL
  187. * @brief Destroy search input.
  188. *
  189. * @par Function
  190. * Can only destroy search input information created
  191. * through aclfvCreateSearchInput interface.
  192. *
  193. * @param searchInput [IN] search input.
  194. *
  195. * @retval ACL_SUCCESS The function is successfully executed.
  196. * @retval OtherValues Failure
  197. *
  198. * @see aclfvCreateSearchInput
  199. */
  200. ACL_FUNC_VISIBILITY aclError aclfvDestroySearchInput(aclfvSearchInput *searchInput);
  201. /**
  202. * @ingroup AscendCL
  203. * @brief Create search result.
  204. *
  205. * @param queryCnt [IN] Retrieve the number of features
  206. * @param resultNum [IN] The number of search results for each feature, the number is queryCnt
  207. * @param resultNumDataLen [IN] resultNum memory length
  208. * @param id0 [IN] Level 1 library id0
  209. * @param id1 [IN] Secondary library id1
  210. * @param resultOffset [IN] The offset of the bottom library corresponding
  211. * to each feature retrieval result, total length topK * queryCnt
  212. * @param resultDistance [IN] Distance, total length topK * queryCnt
  213. * @param dataLen [IN] The memory size requested by
  214. * id0\id1\reslutOffset\resultDistance
  215. *
  216. * @retval null for failed. OtherValues success
  217. */
  218. ACL_FUNC_VISIBILITY aclfvSearchResult *aclfvCreateSearchResult(uint32_t queryCnt, uint32_t *resultNum,
  219. uint32_t resultNumDataLen, uint32_t *id0, uint32_t *id1,
  220. uint32_t *resultOffset, float *resultDistance,
  221. uint32_t dataLen);
  222. /**
  223. * @ingroup AscendCL
  224. * @brief Destroy search result.
  225. *
  226. * @par Function
  227. * Can only destroy search result information created
  228. * through aclfvCreateSearchResult interface.
  229. *
  230. * @param searchResult [IN] search result.
  231. *
  232. * @retval ACL_SUCCESS The function is successfully executed.
  233. * @retval OtherValues Failure
  234. *
  235. * @see aclfvCreateSearchResult
  236. */
  237. ACL_FUNC_VISIBILITY aclError aclfvDestroySearchResult(aclfvSearchResult *searchResult);
  238. /**
  239. * @ingroup AscendCL
  240. * @brief fv IP initialize.
  241. *
  242. * @param initPara [IN] fv init param.
  243. *
  244. * @retval ACL_SUCCESS The function is successfully executed.
  245. * @retval OtherValues Failure.
  246. */
  247. ACL_FUNC_VISIBILITY aclError aclfvInit(aclfvInitPara *initPara);
  248. /**
  249. * @ingroup AscendCL
  250. * @brief release fv resources.
  251. *
  252. * @par Function
  253. * Can only release fv resources created
  254. * through aclfvInit interface.
  255. *
  256. * @retval ACL_SUCCESS The function is successfully executed.
  257. * @retval OtherValues Failure.
  258. *
  259. * @see aclfvInit
  260. */
  261. ACL_FUNC_VISIBILITY aclError aclfvRelease();
  262. /**
  263. * @ingroup AscendCL
  264. * @brief fv repo add.
  265. *
  266. * @param type [IN] repo add type
  267. * @param featureInfo [IN] add feature information
  268. *
  269. * @retval ACL_SUCCESS The function is successfully executed.
  270. * @retval OtherValues Failure.
  271. */
  272. ACL_FUNC_VISIBILITY aclError aclfvRepoAdd(aclfvSearchType type, aclfvFeatureInfo *featureInfo);
  273. /**
  274. * @ingroup AscendCL
  275. * @brief fv repo del.
  276. *
  277. * @param type [IN] repo delete type
  278. * @param repoRange [IN] repo range information
  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);
  284. /**
  285. * @ingroup AscendCL
  286. * @brief fv accurate del.
  287. *
  288. * @param featureInfo [IN] accurate delete feature information
  289. *
  290. * @retval ACL_SUCCESS The function is successfully executed.
  291. * @retval OtherValues Failure.
  292. */
  293. ACL_FUNC_VISIBILITY aclError aclfvDel(aclfvFeatureInfo *featureInfo);
  294. /**
  295. * @ingroup AscendCL
  296. * @brief fv accurate modify.
  297. *
  298. * @param featureInfo [IN] accurate modify feature information
  299. *
  300. * @retval ACL_SUCCESS The function is successfully executed.
  301. * @retval OtherValues Failure.
  302. */
  303. ACL_FUNC_VISIBILITY aclError aclfvModify(aclfvFeatureInfo *featureInfo);
  304. /**
  305. * @ingroup AscendCL
  306. * @brief fv search.
  307. *
  308. * @param type [IN] search type
  309. * @param searchInput [IN] search input
  310. * @param searchRst [OUT] search result
  311. *
  312. * @retval ACL_SUCCESS The function is successfully executed.
  313. * @retval OtherValues Failure.
  314. */
  315. ACL_FUNC_VISIBILITY aclError aclfvSearch(aclfvSearchType type, aclfvSearchInput *searchInput,
  316. aclfvSearchResult *searchRst);
  317. #ifdef __cplusplus
  318. }
  319. #endif
  320. #endif // INC_EXTERNAL_ACL_OPS_ACL_RETR_H_

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