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 8.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261
  1. /* *
  2. * @file acl_fv.h
  3. *
  4. * Copyright (C) Huawei Technologies Co., Ltd. 2019-2020. All Rights Reserved.
  5. *
  6. * This program is distributed in the hope that it will be useful,
  7. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  8. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. */
  10. #ifndef INC_EXTERNAL_ACL_OPS_ACL_RETR_H_
  11. #define INC_EXTERNAL_ACL_OPS_ACL_RETR_H_
  12. #include "../acl.h"
  13. #ifdef __cplusplus
  14. extern "C" {
  15. #endif
  16. typedef struct aclfvFeatureInfo aclfvFeatureInfo;
  17. typedef struct aclfvRepoRange aclfvRepoRange;
  18. typedef struct aclfvQueryTable aclfvQueryTable;
  19. typedef struct aclfvSearchInput aclfvSearchInput;
  20. typedef struct aclfvSearchResult aclfvSearchResult;
  21. // search operation type
  22. enum aclfvSearchType {
  23. SEARCH_1_N, // 1:N operation type
  24. SEARCH_N_M // N:M operation type
  25. };
  26. /* *
  27. * @ingroup AscendCL
  28. * @brief Create fv feature info.
  29. * @param id0 [IN]: The first level library id0
  30. * @param id1 [IN]: Secondary library id1
  31. * @param offset [IN]: The offset of the first feature in the library
  32. * @param featureLen [IN]: Single feature length
  33. * @param featureCount [IN]: Single feature count
  34. * @param featureData [IN/OUT]: Feature value list
  35. * @param featureDataLen [IN]: Feature value list length
  36. * @retval null for failed.
  37. * @retval OtherValues success.
  38. */
  39. ACL_FUNC_VISIBILITY aclfvFeatureInfo *aclfvCreateFeatureInfo(uint32_t id0, uint32_t id1, uint32_t offset,
  40. uint32_t featureLen, uint32_t featureCount, uint8_t *featureData, uint32_t featureDataLen);
  41. /* *
  42. * @ingroup AscendCL
  43. * @brief Destroy fv feature info.
  44. *
  45. * @par Function
  46. * Can only destroy fv feature info information created
  47. * through aclfvCreateFeatureInfo interface.
  48. * @param featureInfo [IN/OUT] fv feature info.
  49. * @retval ACL_ERROR_NONE The function is successfully executed.
  50. * @retval OtherValues Failure
  51. *
  52. * @see aclfvCreateFeatureInfo
  53. */
  54. ACL_FUNC_VISIBILITY aclError aclfvDestroyFeatureInfo(aclfvFeatureInfo *featureInfo);
  55. /* *
  56. * @ingroup AscendCL
  57. * @brief Create fv repo range.
  58. * @param id0Min [IN]: id0 start value
  59. * @param id0Min [IN]: id0 max
  60. * @param id1Min [IN]: id0 start value
  61. * @param id1Max [IN]: id1 max
  62. * @retval null for failed. OtherValues success
  63. */
  64. ACL_FUNC_VISIBILITY aclfvRepoRange *aclfvCreateRepoRange(uint32_t id0Min, uint32_t id0Max, uint32_t id1Min,
  65. uint32_t id1Max);
  66. /* *
  67. * @ingroup AscendCL
  68. * @brief Destroy fv repo range.
  69. *
  70. * @par Function
  71. * Can only destroy fv repo range information created
  72. * through aclfvCreateRepoRange interface.
  73. * @param repoRange [IN/OUT] fv repo range.
  74. * @retval ACL_ERROR_NONE The function is successfully executed.
  75. * @retval OtherValues Failure
  76. *
  77. * @see aclfvCreateRepoRange
  78. */
  79. ACL_FUNC_VISIBILITY aclError aclfvDestroyRepoRange(aclfvRepoRange *repoRange);
  80. /* *
  81. * @ingroup AscendCL
  82. * @brief Create query table.
  83. * @param queryCnt [IN]: Number of tables, the maximum number is 6
  84. * @param tableLen [IN]: Single table length, table length is 32KB
  85. * @param tableData [IN/OUT]: Feature value list
  86. * @param tableDataLen [IN]: The length of memory requested by the featureData
  87. * pointer
  88. * @retval null for failed. OtherValues success
  89. */
  90. ACL_FUNC_VISIBILITY aclfvQueryTable *aclfvCreateQueryTable(uint32_t queryCnt, uint32_t tableLen, uint8_t *tableData,
  91. uint32_t tableDataLen);
  92. /* *
  93. * @ingroup AscendCL
  94. * @brief Destroy query table.
  95. *
  96. * @par Function
  97. * Can only destroy query table information created
  98. * through aclfvCreateQueryTable interface.
  99. * @param queryTable [IN/OUT] query table.
  100. * @retval ACL_ERROR_NONE The function is successfully executed.
  101. * @retval OtherValues Failure
  102. *
  103. * @see aclfvCreateQueryTable
  104. */
  105. ACL_FUNC_VISIBILITY aclError aclfvDestroyQueryTable(aclfvQueryTable *queryTable);
  106. /* *
  107. * @ingroup AscendCL
  108. * @brief Create search input.
  109. * @param queryTable [IN/OUT]: query table
  110. * @param repoRange [IN/OUT]: query repo range
  111. * @param topk [IN]: query topk
  112. * @retval null for failed. OtherValues success
  113. */
  114. ACL_FUNC_VISIBILITY aclfvSearchInput *aclfvCreateSearchInput(aclfvQueryTable *queryTable, aclfvRepoRange *repoRange,
  115. uint32_t topk);
  116. /* *
  117. * @ingroup AscendCL
  118. * @brief Destroy search input.
  119. *
  120. * @par Function
  121. * Can only destroy search input information created
  122. * through aclfvCreateSearchInput interface.
  123. * @param searchInput [IN/OUT] search input.
  124. * @retval ACL_ERROR_NONE The function is successfully executed.
  125. * @retval OtherValues Failure
  126. *
  127. * @see aclfvCreateSearchInput
  128. */
  129. ACL_FUNC_VISIBILITY aclError aclfvDestroySearchInput(aclfvSearchInput *searchInput);
  130. /* *
  131. * @ingroup AscendCL
  132. * @brief Create search result.
  133. * @param queryCnt [IN]: Retrieve the number of features
  134. * @param resultNum [IN/OUT]: The number of search results for each feature, the
  135. * number is queryCnt
  136. * @param resultNumDataLen [IN]: resultNum memory length
  137. * @param id0 [IN/OUT]: Level 1 library id0
  138. * @param id1 [IN/OUT]: Secondary library id1
  139. * @param resultOffset [IN/OUT]: The offset of the bottom library corresponding
  140. * to each feature retrieval result, total length topK * queryCnt
  141. * @param resultDistance [IN/OUT]: Distance, total length topK * queryCnt
  142. * @param dataLen [IN]: The memory size requested by
  143. * id0\id1\reslutOffset\resultDistance
  144. * @retval null for failed. OtherValues success
  145. */
  146. ACL_FUNC_VISIBILITY aclfvSearchResult *aclfvCreateSearchResult(uint32_t queryCnt, uint32_t *resultNum,
  147. uint32_t resultNumDataLen, uint32_t *id0, uint32_t *id1, uint32_t *resultOffset, float *resultDistance,
  148. uint32_t dataLen);
  149. /* *
  150. * @ingroup AscendCL
  151. * @brief Destroy search result.
  152. *
  153. * @par Function
  154. * Can only destroy search result information created
  155. * through aclfvCreateSearchResult interface.
  156. * @param searchResult [IN/OUT] search result.
  157. * @retval ACL_ERROR_NONE The function is successfully executed.
  158. * @retval OtherValues Failure
  159. *
  160. * @see aclfvCreateSearchResult
  161. */
  162. ACL_FUNC_VISIBILITY aclError aclfvDestroySearchResult(aclfvSearchResult *searchResult);
  163. /* *
  164. * @ingroup AscendCL
  165. * @brief fv IP initialize.
  166. *
  167. * @param fsNum [IN] max repo num, used to apply for memory.
  168. * @retval ACL_ERROR_NONE The function is successfully executed.
  169. * @retval OtherValues Failure.
  170. */
  171. ACL_FUNC_VISIBILITY aclError aclfvInit(uint64_t fsNum);
  172. /* *
  173. * @ingroup AscendCL
  174. * @brief release fv resources.
  175. *
  176. * @par Function
  177. * Can only release fv resources created
  178. * through aclfvInit interface.
  179. * @retval ACL_ERROR_NONE The function is successfully executed.
  180. * @retval OtherValues Failure.
  181. *
  182. * @see aclfvInit
  183. */
  184. ACL_FUNC_VISIBILITY aclError aclfvRelease();
  185. /* *
  186. * @ingroup AscendCL
  187. * @brief fv repo add.
  188. * @param type [IN]: repo add type
  189. * @param featureInfo [IN/OUT]: add feature information
  190. * @param stream [IN]: stream of task execute
  191. * @retval ACL_ERROR_NONE The function is successfully executed.
  192. * @retval OtherValues Failure.
  193. */
  194. ACL_FUNC_VISIBILITY aclError aclfvRepoAdd(aclfvSearchType type, aclfvFeatureInfo *featureInfo, aclrtStream stream);
  195. /* *
  196. * @ingroup AscendCL
  197. * @brief fv repo del.
  198. * @param type [IN]: repo delete type
  199. * @param repoRange [IN/OUT]: repo range information
  200. * @param stream [IN]: stream of task execute
  201. * @retval ACL_ERROR_NONE The function is successfully executed.
  202. * @retval OtherValues Failure.
  203. */
  204. ACL_FUNC_VISIBILITY aclError aclfvRepoDel(aclfvSearchType type, aclfvRepoRange *repoRange, aclrtStream stream);
  205. /* *
  206. * @ingroup AscendCL
  207. * @brief fv accurate del.
  208. * @param featureInfo [IN/OUT]: accurate delete feature information
  209. * @param stream [IN]: stream of task execute
  210. * @retval ACL_ERROR_NONE The function is successfully executed.
  211. * @retval OtherValues Failure.
  212. */
  213. ACL_FUNC_VISIBILITY aclError aclfvDel(aclfvFeatureInfo *featureInfo, aclrtStream stream);
  214. /* *
  215. * @ingroup AscendCL
  216. * @brief fv accurate modify.
  217. * @param featureInfo [IN/OUT]: accurate modify feature information
  218. * @param stream [IN]: stream of task execute
  219. * @retval ACL_ERROR_NONE The function is successfully executed.
  220. * @retval OtherValues Failure.
  221. */
  222. ACL_FUNC_VISIBILITY aclError aclfvModify(aclfvFeatureInfo *featureInfo, aclrtStream stream);
  223. /* *
  224. * @ingroup AscendCL
  225. * @brief fv search.
  226. * @param type [IN]: search type
  227. * @param searchInput [IN/OUT]: search input
  228. * @param searchRst [IN/OUT]: search result
  229. * @param stream [IN]: stream of task execute
  230. * @retval ACL_ERROR_NONE The function is successfully executed.
  231. * @retval OtherValues Failure.
  232. */
  233. ACL_FUNC_VISIBILITY aclError aclfvSearch(aclfvSearchType type, aclfvSearchInput *searchInput,
  234. aclfvSearchResult *searchRst, aclrtStream stream);
  235. #ifdef __cplusplus
  236. }
  237. #endif
  238. #endif // INC_EXTERNAL_ACL_OPS_ACL_RETR_H_

MegEngine 安装包中集成了使用 GPU 运行代码所需的 CUDA 环境,不用区分 CPU 和 GPU 版。 如果想要运行 GPU 程序,请确保机器本身配有 GPU 硬件设备并安装好驱动。 如果你想体验在云端 GPU 算力平台进行深度学习开发的感觉,欢迎访问 MegStudio 平台