diff --git a/CMakeLists.txt b/CMakeLists.txt index 49aece979067899c4ec32a98f223b639f346ed86..2a1252aacde69748148588555fd8c1d188b30d52 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 cc52595074138c9ebbcc0a92c9de9c1e16a15a7f..e2fc381b0e295a3bf59660a204dafafdd3454256 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,