已合并
【fix】重命名自定义算子so #174
Qanly创建于 15 天前
【fix】重命名自定义算子so #174
已合并
Qanly创建于 15 天前
5 个文件变更+15-9
@@ -34,7 +34,7 @@ include_directories(
34set(COMMON_LIBS34set(COMMON_LIBS
35 ${ASCEND_PATH}/lib64/libascendcl.so35 ${ASCEND_PATH}/lib64/libascendcl.so
36 ${ASCEND_PATH}/lib64/libnnopbase.so36 ${ASCEND_PATH}/lib64/libnnopbase.so
37- ${TARGET_SUBDIR}/op_api/lib/libcust_opapi.so37+ ${TARGET_SUBDIR}/op_api/lib/libfaiss_npu_opapi.so
38)38)
39set(COMMON_LINK_OPTIONS "-Wl,-rpath,${TARGET_SUBDIR}/op_api/lib")39set(COMMON_LINK_OPTIONS "-Wl,-rpath,${TARGET_SUBDIR}/op_api/lib")
40 40 
@@ -36,4 +36,6 @@ function(pack_custom)
36 cust_opmaster36 cust_opmaster
37 )37 )
38 endif()38 endif()
39+ # Override default output name: libcust_opapi.so -> libfaiss_npu_opapi.so
40+ set_target_properties(${PACK_CUSTOM_NAME}_ascendc_cust_opapi PROPERTIES OUTPUT_NAME faiss_npu_opapi)
39endfunction()41endfunction()
@@ -16,7 +16,7 @@ SOC_MAP=([Ascend310P]="Ascend310P3"
16 16 
17OPC_TASK_NAME="opc_cmd.sh"17OPC_TASK_NAME="opc_cmd.sh"
18OUT_TASK_NAME="out_cmd.sh"18OUT_TASK_NAME="out_cmd.sh"
19-OP_CATEGORY_LIST="math conversion examples"19+OP_CATEGORY_LIST="conversion"
20 20 
21function trans_soc() {21function trans_soc() {
22 local _soc_input=$122 local _soc_input=$1
@@ -100,7 +100,8 @@ size_t getFreeMemoryCurrentDevice() {
100 100 
101DeviceScope::DeviceScope(int device) {101DeviceScope::DeviceScope(int device) {
102 if (device >= 0) {102 if (device >= 0) {
103- // Try to get current device, but handle the case where no device context exists103+ // Try to get current device, but handle the case where no device
104+ // context exists
104 int curDevice = -1;105 int curDevice = -1;
105 aclError err = aclrtGetDevice(&curDevice);106 aclError err = aclrtGetDevice(&curDevice);
106 if (err == ACL_SUCCESS && curDevice >= 0 && curDevice != device) {107 if (err == ACL_SUCCESS && curDevice >= 0 && curDevice != device) {
@@ -201,7 +202,10 @@ std::vector<std::string> getCustLibPath() {
201}202}
202 203 
203// Helper function to get function address from a library handle204// Helper function to get function address from a library handle
204-void* getOpApiFuncAddrInLib(void* handler, const char* libName, const char* apiName) {205+void* getOpApiFuncAddrInLib(
206+ void* handler,
207+ const char* libName,
208+ const char* apiName) {
205 if (handler == nullptr) {209 if (handler == nullptr) {
206 return nullptr;210 return nullptr;
207 }211 }
@@ -228,7 +232,7 @@ void* getOpApiLibHandler(const char* libName) {
228}232}
229 233 
230const char* getCustOpApiLibName() {234const char* getCustOpApiLibName() {
231- return "libcust_opapi.so";235+ return "libfaiss_npu_opapi.so";
232}236}
233} // namespace237} // namespace
234 238 
@@ -250,8 +254,8 @@ void* getOpApiFuncAddr(const char* apiName) {
250 }254 }
251 }255 }
252 }256 }
253- 257+ 
254- // 2. Try to load libcust_opapi.so directly (using static handler)258+ // 2. Try to load libfaiss_npu_opapi.so directly (using static handler)
255 static void* opApiHandler = getOpApiLibHandler(getCustOpApiLibName());259 static void* opApiHandler = getOpApiLibHandler(getCustOpApiLibName());
256 if (opApiHandler == nullptr) {260 if (opApiHandler == nullptr) {
257 return nullptr;261 return nullptr;
@@ -54,9 +54,9 @@ size_t getFreeMemoryCurrentDevice();
54 54 
55/// Get operator API function address by name.55/// Get operator API function address by name.
56/// Searches for the function in56/// Searches for the function in
57-/// ASCEND_OPP_PATH/vendors/*/op_api/lib/libcust_opapi.so according to57+/// ASCEND_OPP_PATH/vendors/*/op_api/lib/libfaiss_npu_opapi.so according to
58/// load_priority in config.ini, then falls back to RTLD_DEFAULT and finally58/// load_priority in config.ini, then falls back to RTLD_DEFAULT and finally
59-/// tries to load libcust_opapi.so directly.59+/// tries to load libfaiss_npu_opapi.so directly.
60void* getOpApiFuncAddr(const char* apiName);60void* getOpApiFuncAddr(const char* apiName);
61 61 
62/// Typed wrapper around `getOpApiFuncAddr` to keep call sites consistent.62/// Typed wrapper around `getOpApiFuncAddr` to keep call sites consistent.