From 5c40064651fa9891c65cb2459114f7d9ae2f93ca Mon Sep 17 00:00:00 2001 From: zhuceHW Date: Tue, 2 Sep 2025 16:12:16 +0800 Subject: [PATCH] 1. fix bug of symbol not found when AOTInductor run --- CMakeLists.txt | 6 ++++++ torch_npu/csrc/inductor/aoti_torch/shim_npu.cpp | 2 -- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 49aece9790..2a1252aacd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,8 @@ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O2 -g") SET(CMAKE_CXX_FLAGS_RELEASE "-O2") SET(CMAKE_CXX_FLAGS_DEBUG "-O0 -g") +option(USE_NPU "Use NPU" ON) + # LTO&PGO optimization in compile option SET(IF_APPEND FALSE) if ("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") @@ -95,6 +97,10 @@ ELSE() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DNDEBUG") ENDIF() +if(USE_NPU) + string(APPEND CMAKE_CXX_FLAGS " -DUSE_NPU") +endif() + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-narrowing") # Eigen fails to build with some versions, so convert this to a warning diff --git a/torch_npu/csrc/inductor/aoti_torch/shim_npu.cpp b/torch_npu/csrc/inductor/aoti_torch/shim_npu.cpp index cc52595074..e2fc381b0e 100644 --- a/torch_npu/csrc/inductor/aoti_torch/shim_npu.cpp +++ b/torch_npu/csrc/inductor/aoti_torch/shim_npu.cpp @@ -32,7 +32,6 @@ namespace { } } // namespace -#ifdef USE_NPU AOTITorchError aoti_torch_create_npu_guard(int32_t device_index, NPUGuardHandle* ret_guard) { // todo: implement create npu guard logic @@ -65,7 +64,6 @@ AOTITorchError aoti_torch_delete_npu_stream_guard(NPUStreamGuardHandle guard) // todo: implement delete npu stream guard logic return AOTI_TORCH_SUCCESS; } -#endif // USE_NPU AOTITorchError aoti_torch_create_tensor_from_blob_npu( void* data, -- Gitee