This is an automated email from the ASF dual-hosted git repository.
tqchen pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tvm.git
The following commit(s) were added to refs/heads/main by this push:
new 027144beb0 [CMake] Use typed parent options and retire config.cmake
(#20764)
027144beb0 is described below
commit 027144beb07d2d5463b402fda7d9f73ae94dd2b3
Author: Tianqi Chen <[email protected]>
AuthorDate: Fri Oct 16 15:00:16 2026 -0400
[CMake] Use typed parent options and retire config.cmake (#20764)
Replace the parent build's legacy option registry and config.cmake
workflow with typed TVM_USE_* settings and native CMake arguments.
Migrate repository scripts, CI, examples, and documentation to the same
configuration interface, including explicit SDK selectors.
Apply compiler properties and dependency requirements to their consuming
parent targets while preserving source-built and installed TIRx
integration, third-party shared-library APIs, relative library paths,
and package-owned install components.
---
.gitignore | 2 +-
AGENTS.md | 4 +-
CMakeLists.txt | 245 ++++++++--------
apps/cpp_rpc/CMakeLists.txt | 3 +-
apps/cpp_rpc/README.md | 68 ++---
apps/ios_rpc/README.md | 4 +-
apps/ios_rpc/tvmrpc/RPCServer.mm | 2 +-
ci/jenkins/artifacts.py | 4 +-
cmake/config.cmake | 307 ---------------------
cmake/modules/RuntimeExtra.cmake | 51 ++--
cmake/modules/contrib/AMX.cmake | 5 +-
cmake/modules/contrib/BLAS.cmake | 43 +--
cmake/modules/contrib/CLML.cmake | 34 +--
cmake/modules/contrib/CUDA.cmake | 68 +++--
cmake/modules/contrib/CUTLASS.cmake | 10 +-
cmake/modules/contrib/CoreML.cmake | 7 +-
cmake/modules/contrib/DNNL.cmake | 32 ++-
cmake/modules/contrib/ExampleNPU.cmake | 16 +-
cmake/modules/contrib/NNAPI.cmake | 16 +-
cmake/modules/contrib/ROCM.cmake | 16 +-
cmake/modules/contrib/Random.cmake | 7 +-
cmake/modules/contrib/Sort.cmake | 7 +-
cmake/modules/contrib/TensorRT.cmake | 29 +-
cmake/modules/contrib/vllm.cmake | 9 +-
cmake/utils/CCache.cmake | 24 +-
cmake/utils/FindNVSHMEM.cmake | 6 +-
cmake/utils/Library.cmake | 98 +++----
cmake/utils/Linker.cmake | 16 +-
cmake/utils/Summary.cmake | 77 ------
cmake/utils/Utils.cmake | 78 ------
docs/contribute/testing.rst | 6 +-
docs/errors.rst | 4 +-
docs/how_to/tutorials/bring_your_own_codegen.py | 4 +-
docs/how_to/tutorials/cross_compilation_and_rpc.py | 18 +-
docs/install/from_source.rst | 82 +++---
docs/tirx/install.rst | 4 +-
.../src/main/java/org/apache/tvm/rpc/Client.java | 2 +-
.../relax/backend/contrib/example_npu/README.md | 9 +-
python/tvm/rpc/client.py | 2 +-
python/tvm/rpc/server.py | 4 +-
.../tvm/s_tir/meta_schedule/runner/rpc_runner.py | 2 +-
src/runtime/extra/contrib/clml/clml_runtime.cc | 4 +-
src/runtime/extra/contrib/nnapi/nnapi_runtime.cc | 4 +-
.../extra/contrib/tensorrt/tensorrt_runtime.cc | 6 +-
.../extra/contrib/tensorrt/tensorrt_utils.h | 3 +-
tests/cpp/CMakeLists.txt | 15 +-
.../relax/test_tensorrt_engine_serialization.py | 2 +-
tests/scripts/release/test_release_package.sh | 3 +-
tests/scripts/task_build_arm.sh | 9 +-
tests/scripts/task_build_cpu.sh | 18 +-
tests/scripts/task_build_gpu.sh | 21 +-
tests/scripts/task_build_gpu_other.sh | 2 +-
tests/scripts/task_build_wasm.sh | 9 +-
53 files changed, 524 insertions(+), 997 deletions(-)
diff --git a/.gitignore b/.gitignore
index e5ea924a3d..b3c8bf941d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -101,7 +101,7 @@ ENV/
*.pyc
*~
config.mk
-config.cmake
+CMakeUserPresets.json
Win32
*.dir
perf
diff --git a/AGENTS.md b/AGENTS.md
index cd38b2adf3..d0b85a6cee 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -54,8 +54,8 @@ For a fresh checkout, initialize submodules and configure
CMake first:
```bash
git submodule update --init --recursive
mkdir -p build
-cp cmake/config.cmake build/config.cmake
-cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
+cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF
cmake --build build --parallel
```
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7de082bce4..dcf2997167 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -15,14 +15,75 @@
# specific language governing permissions and limitations
# under the License.
-cmake_minimum_required(VERSION 3.18)
+cmake_minimum_required(VERSION 3.24)
+if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
+ set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Export compilation
commands")
+endif()
project(tvm C CXX)
include(GNUInstallDirs)
-if(EXISTS "${CMAKE_BINARY_DIR}/config.cmake")
- include("${CMAKE_BINARY_DIR}/config.cmake")
-elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/config.cmake")
- include("${CMAKE_CURRENT_SOURCE_DIR}/config.cmake")
-endif()
+
+# Declare native boolean switches and typed cache settings uniformly.
+function(tvm_option variable type default description)
+ if(type STREQUAL "BOOL")
+ option(${variable} "${description}" "${default}")
+ else()
+ set(${variable} "${default}" CACHE ${type} "${description}")
+ endif()
+endfunction()
+
+# ######### Common options ##########
+
+tvm_option(TVM_USE_RPC BOOL ON "Build with RPC")
+tvm_option(TVM_USE_CPP_RPC BOOL OFF "Build CPP RPC")
+tvm_option(TVM_USE_IOS_RPC BOOL OFF "Build iOS RPC")
+tvm_option(TVM_LOG_BEFORE_THROW BOOL OFF "Whether log before throw, for
debugging purposes")
+tvm_option(TVM_USE_MSVC_MT BOOL OFF "Build with MT")
+tvm_option(TVM_HIDE_PRIVATE_SYMBOLS BOOL ON "Compile with
-fvisibility=hidden.")
+tvm_option(TVM_USE_GTEST STRING AUTO "Use GoogleTest for C++ sanity tests
(OFF, ON, AUTO)")
+tvm_option(TVM_USE_CCACHE STRING AUTO "Use ccache (OFF, ON, AUTO, or
executable path)")
+tvm_option(TVM_USE_ALTERNATIVE_LINKER STRING AUTO "Use 'mold' or 'lld' if
found when invoking compiler to link artifact")
+
+# ######### CPU libraries ##########
+
+tvm_option(TVM_USE_BLAS STRING none "The blas library to be linked")
+tvm_option(TVM_USE_MKL STRING OFF "Build with MKL (OFF, ON, or SDK path)")
+tvm_option(TVM_USE_DNNL STRING OFF "Build with DNNL (OFF, ON, JSON, C_SRC, or
SDK path)")
+tvm_option(TVM_USE_AMX BOOL OFF "Enable Intel AMX")
+tvm_option(TVM_USE_SORT BOOL ON "Build with sort support")
+tvm_option(TVM_USE_RANDOM BOOL ON "Build with random support")
+
+# ######### GPU libraries ##########
+
+tvm_option(TVM_USE_NCCL STRING OFF "Build with NCCL (OFF, ON, or SDK path)")
+tvm_option(TVM_USE_RCCL STRING OFF "Build with RCCL (OFF, ON, or SDK path)")
+tvm_option(TVM_USE_NVSHMEM STRING OFF "Build with NVSHMEM (OFF, ON, or SDK
path)")
+tvm_option(TVM_USE_CUDNN STRING OFF "Build with cuDNN (OFF, ON, or SDK path)")
+tvm_option(TVM_USE_CUDNN_FRONTEND STRING OFF "Build with cuDNN frontend (OFF,
ON, or include root)")
+tvm_option(TVM_USE_CUBLAS BOOL OFF "Build with cuBLAS")
+tvm_option(TVM_USE_NVTX BOOL OFF "Build with NVTX")
+tvm_option(TVM_USE_CUTLASS BOOL OFF "Build with CUTLASS")
+tvm_option(TVM_USE_THRUST STRING OFF "Build with Thrust (OFF, ON, or CCCL
path)")
+tvm_option(TVM_USE_CURAND BOOL OFF "Build with cuRAND")
+tvm_option(TVM_USE_HIPBLAS BOOL OFF "Build with ROCM:HIPBLAS")
+tvm_option(TVM_USE_VLLM BOOL OFF "Build with vLLM support")
+
+# ######### External code generators and runtimes ##########
+
+tvm_option(TVM_USE_COREML BOOL OFF "Build with coreml support")
+tvm_option(TVM_USE_TENSORRT_CODEGEN BOOL OFF "Build with TensorRT Codegen
support")
+tvm_option(TVM_USE_TENSORRT_RUNTIME STRING OFF "Build with TensorRT runtime
(OFF, ON, or SDK path)")
+tvm_option(TVM_USE_NNAPI_CODEGEN BOOL OFF "Build with NNAPI Codegen support")
+tvm_option(TVM_USE_NNAPI_RUNTIME BOOL OFF "Build with NNAPI runtime")
+tvm_option(TVM_USE_EXAMPLE_NPU_CODEGEN BOOL OFF "Build with Example NPU
Codegen support")
+tvm_option(TVM_USE_EXAMPLE_NPU_RUNTIME BOOL OFF "Build with Example NPU
runtime")
+tvm_option(TVM_USE_CLML STRING OFF "Build with CLML codegen (OFF, ON, or SDK
path)")
+tvm_option(TVM_USE_CLML_GRAPH_EXECUTOR STRING OFF "Build with CLML graph
runtime (OFF, ON, or SDK path)")
+
+set_property(CACHE TVM_USE_BLAS PROPERTY STRINGS none openblas atlas blas
apple)
+set_property(CACHE TVM_USE_GTEST PROPERTY STRINGS AUTO ON OFF)
+
+# ######### Core dependencies ##########
+
set(_installed_tirx ON)
if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/tirx/CMakeLists.txt")
set(_installed_tirx OFF)
@@ -32,11 +93,11 @@ option(TVM_BUILD_PYTHON_MODULE "Build Python module with
scikit-build-core" OFF)
if(TVM_BUILD_PYTHON_MODULE)
set(CMAKE_INSTALL_LIBDIR lib)
endif()
-if(USE_CLML_GRAPH_EXECUTOR)
- if(USE_CLML_GRAPH_EXECUTOR STREQUAL "ON")
+if(TVM_USE_CLML_GRAPH_EXECUTOR)
+ if(TVM_USE_CLML_GRAPH_EXECUTOR STREQUAL "ON")
set(TVM_TIRX_USE_OPENCL "${CMAKE_CURRENT_SOURCE_DIR}/clml")
else()
- set(TVM_TIRX_USE_OPENCL "${USE_CLML_GRAPH_EXECUTOR}")
+ set(TVM_TIRX_USE_OPENCL "${TVM_USE_CLML_GRAPH_EXECUTOR}")
endif()
endif()
if(TVM_USE_INSTALLED_TIRX)
@@ -71,7 +132,8 @@ if(TVM_USE_INSTALLED_TIRX)
unset(_tirx_backend_library)
endforeach()
foreach(_backend CUDA ROCM)
- if(NOT DEFINED TVM_TIRX_USE_${_backend})
+ # Installed packages expose libraries, not cached build-option state.
+ if(NOT DEFINED TVM_TIRX_USE_${_backend} OR "${TVM_TIRX_USE_${_backend}}"
MATCHES "^[Aa][Uu][Tt][Oo]$")
string(TOLOWER "${_backend}" _backend_lower)
set(TVM_TIRX_USE_${_backend} OFF)
if(TARGET tvm_runtime_${_backend_lower})
@@ -112,15 +174,18 @@ else()
unset(CMAKE_${_kind}_OUTPUT_DIRECTORY)
endforeach()
endif()
-foreach(_utility Utils Summary Linker Library CCache)
- include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils/${_utility}.cmake")
-endforeach()
-foreach(_utility FindCUDA FindROCM FindOpenCL)
- include("${TVM_TIRX_CMAKE_DIR}/utils/${_utility}.cmake")
-endforeach()
-foreach(_collective NCCL RCCL NVSHMEM)
- include("${CMAKE_CURRENT_SOURCE_DIR}/cmake/utils/Find${_collective}.cmake")
-endforeach()
+# ######### Parent build settings ##########
+
+include(cmake/utils/Utils.cmake)
+include(cmake/utils/Linker.cmake)
+include(cmake/utils/Library.cmake)
+include(cmake/utils/CCache.cmake)
+include("${TVM_TIRX_CMAKE_DIR}/utils/FindCUDA.cmake")
+include("${TVM_TIRX_CMAKE_DIR}/utils/FindROCM.cmake")
+include("${TVM_TIRX_CMAKE_DIR}/utils/FindOpenCL.cmake")
+include(cmake/utils/FindNCCL.cmake)
+include(cmake/utils/FindRCCL.cmake)
+include(cmake/utils/FindNVSHMEM.cmake)
if(NOT TARGET tvm_ffi_header)
add_library(tvm_ffi_header ALIAS tvm_ffi::header)
endif()
@@ -129,79 +194,19 @@ if(NOT TARGET tvm_runtime)
add_library(tvm_runtime ALIAS tvm_runtime::shared)
endif()
set(BUILD_FOR_ANDROID "${ANDROID}")
-set(CMAKE_CXX_STANDARD 20)
-set(CMAKE_CXX_STANDARD_REQUIRED ON)
-set(CMAKE_CUDA_STANDARD 20)
-set(CMAKE_CUDA_STANDARD_REQUIRED ON)
-set(CMAKE_POSITION_INDEPENDENT_CODE ON)
-set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-tvm_option(USE_NCCL "Build with NCCL" OFF)
-tvm_option(USE_RCCL "Build with RCCL" OFF)
-tvm_option(USE_RPC "Build with RPC" ON)
-tvm_option(TVM_LOG_BEFORE_THROW "Whether log before throw, for debugging
purposes" OFF)
-tvm_option(USE_MSVC_MT "Build with MT" OFF)
-tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF)
-tvm_option(HIDE_PRIVATE_SYMBOLS "Compile with -fvisibility=hidden." ON)
-tvm_option(INDEX_DEFAULT_I64 "Defaults the index datatype to int64" ON)
-tvm_option(USE_GTEST "Use GoogleTest for C++ sanity tests" AUTO)
-tvm_option(USE_ALTERNATIVE_LINKER "Use 'mold' or 'lld' if found when invoking
compiler to link artifact" AUTO)
-tvm_option(USE_BLAS "The blas library to be linked" none)
-tvm_option(USE_AMX "Enable Intel AMX" OFF)
-tvm_option(USE_MKL "MKL root path when use MKL blas" OFF)
-tvm_option(USE_DNNL "Enable DNNL codegen" OFF)
-tvm_option(USE_CUDNN "Build with cuDNN" OFF)
-tvm_option(USE_CUBLAS "Build with cuBLAS" OFF)
-tvm_option(USE_NVTX "Build with NVTX" OFF)
-tvm_option(USE_CUTLASS "Build with CUTLASS" OFF)
-tvm_option(USE_THRUST "Build with Thrust" OFF)
-tvm_option(USE_CURAND "Build with cuRAND" OFF)
-tvm_option(USE_HIPBLAS "Build with ROCM:HIPBLAS" OFF)
-tvm_option(USE_SORT "Build with sort support" ON)
-tvm_option(USE_RANDOM "Build with random support" ON)
-tvm_option(USE_CPP_RPC "Build CPP RPC" OFF)
-tvm_option(USE_IOS_RPC "Build iOS RPC" OFF)
-tvm_option(USE_COREML "Build with coreml support" OFF)
-tvm_option(USE_TENSORRT_CODEGEN "Build with TensorRT Codegen support" OFF)
-tvm_option(USE_TENSORRT_RUNTIME "Build with TensorRT runtime" OFF)
-tvm_option(USE_NNAPI_CODEGEN "Build with NNAPI Codegen support" OFF)
-tvm_option(USE_NNAPI_RUNTIME "Build with NNAPI runtime" OFF)
-tvm_option(USE_EXAMPLE_NPU_CODEGEN "Build with Example NPU Codegen support"
OFF)
-tvm_option(USE_EXAMPLE_NPU_RUNTIME "Build with Example NPU runtime" OFF)
-tvm_option(SUMMARIZE "Print CMake option summary after configuring" OFF)
-tvm_option(USE_CLML "Build with CLML Codegen support" OFF)
-tvm_option(USE_CLML_GRAPH_EXECUTOR "Build with CLML graph runtime" OFF)
-tvm_option(USE_NVSHMEM "Build with NVSHMEM support" OFF)
-
-include_directories(include)
-if(MSVC)
- add_compile_definitions(WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS
- _SCL_SECURE_NO_WARNINGS _ENABLE_EXTENDED_ALIGNED_STORAGE NOMINMAX)
- add_compile_options(/bigobj /permissive- /EHsc)
- if(USE_MSVC_MT)
- set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
- endif()
-else()
- add_compile_options(-Wall)
- if(APPLE)
- set(TVM_NO_UNDEFINED_SYMBOLS "-Wl,-undefined,error")
- else()
- set(TVM_NO_UNDEFINED_SYMBOLS "-Wl,--no-undefined")
- endif()
-endif()
-if(DEFINED TVM_VERSION)
- add_compile_definitions(TVM_VERSION="${TVM_VERSION}")
-elseif(DEFINED SKBUILD_PROJECT_VERSION_FULL)
- add_compile_definitions(TVM_VERSION="${SKBUILD_PROJECT_VERSION_FULL}")
-else()
- add_compile_definitions(TVM_VERSION="0.28.dev0")
+if(DEFINED SKBUILD_PROJECT_VERSION_FULL AND NOT DEFINED TVM_VERSION)
+ set(TVM_VERSION "${SKBUILD_PROJECT_VERSION_FULL}")
+elseif(NOT DEFINED TVM_VERSION)
+ set(TVM_VERSION "0.28.dev0")
endif()
-if(TVM_LOG_BEFORE_THROW)
- add_compile_definitions(TVM_LOG_BEFORE_THROW=1)
-endif()
-set(TVM_LINKER_LIBS "")
-set(TVM_RUNTIME_LINKER_LIBS "")
+find_and_set_linker("${TVM_USE_ALTERNATIVE_LINKER}")
+
+# ######### Compiler and runtime extensions ##########
+
+add_library(tvm_compiler SHARED)
+tvm_configure_target(tvm_compiler)
set(TVM_RUNTIME_BACKEND_LIBS "")
-tvm_file_glob(GLOB_RECURSE COMPILER_SRCS
+file(GLOB_RECURSE COMPILER_SRCS CONFIGURE_DEPENDS
src/te/*.cc
src/s_tir/*.cc
src/topi/*.cc
@@ -224,20 +229,19 @@ tvm_file_glob(GLOB_RECURSE COMPILER_SRCS
# Timing, VM, RPC, Disco and optional integrations remain parent runtime
extensions.
add_library(tvm_runtime_extra SHARED)
+tvm_configure_target(tvm_runtime_extra)
add_library(tvm_runtime_extra_defs INTERFACE)
target_link_libraries(tvm_runtime_extra_defs INTERFACE
tvm_runtime::shared tvm_ffi::shared)
target_include_directories(tvm_runtime_extra_defs SYSTEM INTERFACE
"${CMAKE_CURRENT_SOURCE_DIR}/tirx/3rdparty/compiler-rt")
target_compile_definitions(tvm_runtime_extra_defs INTERFACE
TVM_RUNTIME_EXTRA_EXPORTS TVM_FFI_EXPORTS)
-if(HIDE_PRIVATE_SYMBOLS AND NOT MSVC)
- target_compile_options(tvm_runtime_extra_defs INTERFACE -fvisibility=hidden)
-endif()
+target_compile_features(tvm_runtime_extra_defs INTERFACE cxx_std_20)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_runtime_extra_defs)
-tvm_file_glob(GLOB _vm_sources src/runtime/vm/*.cc src/runtime/rpc/minrpc/*.cc)
+file(GLOB _vm_sources CONFIGURE_DEPENDS src/runtime/vm/*.cc
src/runtime/rpc/minrpc/*.cc)
target_sources(tvm_runtime_extra PRIVATE src/runtime/timer.cc ${_vm_sources})
-if(USE_RPC)
- tvm_file_glob(GLOB _rpc_sources src/runtime/rpc/*.cc)
+if(TVM_USE_RPC)
+ file(GLOB _rpc_sources CONFIGURE_DEPENDS src/runtime/rpc/*.cc)
target_sources(tvm_runtime_extra PRIVATE ${_rpc_sources})
if(WIN32)
target_link_libraries(tvm_runtime_extra PRIVATE ws2_32)
@@ -247,13 +251,19 @@ if(TVM_TIRX_USE_CUDA)
if(NOT TARGET tvm_runtime_cuda)
message(FATAL_ERROR "Parent CUDA support requires a CUDA-enabled core")
endif()
- find_cuda(${TVM_TIRX_USE_CUDA} ${USE_CUDNN})
+ # The frontend also compiles and links against the cuDNN library.
+ if(TVM_USE_CUDNN_FRONTEND AND NOT TVM_USE_CUDNN)
+ find_cuda(${TVM_TIRX_USE_CUDA} ON)
+ else()
+ find_cuda(${TVM_TIRX_USE_CUDA} ${TVM_USE_CUDNN})
+ endif()
enable_language(CUDA)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES native)
endif()
- include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
- tvm_file_glob(GLOB _vm_cuda_sources src/runtime/vm/cuda/*.cc)
+ target_include_directories(tvm_runtime_extra_defs SYSTEM INTERFACE
${CUDA_INCLUDE_DIRS})
+ target_include_directories(tvm_compiler SYSTEM PRIVATE ${CUDA_INCLUDE_DIRS})
+ file(GLOB _vm_cuda_sources CONFIGURE_DEPENDS src/runtime/vm/cuda/*.cc)
target_sources(tvm_runtime_extra PRIVATE ${_vm_cuda_sources})
endif()
if(TVM_TIRX_USE_ROCM)
@@ -265,10 +275,12 @@ if(TVM_TIRX_USE_ROCM)
else()
find_rocm(${TVM_TIRX_USE_ROCM})
endif()
- include_directories(SYSTEM ${ROCM_INCLUDE_DIRS})
- add_compile_definitions(__HIP_PLATFORM_HCC__=1 __HIP_PLATFORM_AMD__=1)
+ target_include_directories(tvm_runtime_extra_defs SYSTEM INTERFACE
${ROCM_INCLUDE_DIRS})
+ target_compile_definitions(tvm_runtime_extra_defs INTERFACE
__HIP_PLATFORM_HCC__=1 __HIP_PLATFORM_AMD__=1)
+ target_include_directories(tvm_compiler SYSTEM PRIVATE ${ROCM_INCLUDE_DIRS})
+ target_compile_definitions(tvm_compiler PRIVATE __HIP_PLATFORM_HCC__=1
__HIP_PLATFORM_AMD__=1)
endif()
-if(USE_NVTX)
+if(TVM_USE_NVTX)
target_compile_definitions(tvm_runtime_extra_defs INTERFACE
TVM_NVTX_ENABLED=1)
endif()
include(cmake/modules/contrib/CUDA.cmake)
@@ -285,7 +297,7 @@ include(cmake/modules/contrib/TensorRT.cmake)
include(cmake/modules/contrib/NNAPI.cmake)
include(cmake/modules/contrib/ExampleNPU.cmake)
include(cmake/modules/contrib/vllm.cmake)
-if(USE_CLML_GRAPH_EXECUTOR)
+if(TVM_USE_CLML_GRAPH_EXECUTOR)
target_link_libraries(tvm_clml_objs PRIVATE tvm_runtime_opencl)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_runtime_opencl)
endif()
@@ -296,21 +308,21 @@ if(TARGET tvm_clml_objs)
endif()
# Retain the upstream runtime-extra assembly module and its target composition.
include(cmake/modules/RuntimeExtra.cmake)
-target_link_libraries(tvm_runtime_extra PRIVATE ${TVM_RUNTIME_LINKER_LIBS}
${CMAKE_DL_LIBS})
-add_library(tvm_compiler SHARED ${COMPILER_SRCS})
-if(HIDE_PRIVATE_SYMBOLS AND NOT MSVC)
- target_compile_options(tvm_compiler PRIVATE -fvisibility=hidden)
-endif()
+target_link_libraries(tvm_runtime_extra PRIVATE ${CMAKE_DL_LIBS})
+target_sources(tvm_compiler PRIVATE ${COMPILER_SRCS})
target_compile_definitions(tvm_compiler PRIVATE TVM_EXPORTS TVM_FFI_EXPORTS)
target_link_libraries(tvm_compiler PUBLIC tvm_tirx_compiler::shared
tvm_ffi::shared tvm_runtime_extra)
-target_link_libraries(tvm_compiler PRIVATE ${TVM_LINKER_LIBS})
target_include_directories(tvm_compiler SYSTEM PRIVATE
"${CMAKE_CURRENT_SOURCE_DIR}/tirx/3rdparty/compiler-rt")
foreach(_target tvm_compiler tvm_runtime_extra)
target_include_directories(${_target} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
- target_link_options(${_target} PRIVATE ${TVM_NO_UNDEFINED_SYMBOLS})
+ if(APPLE)
+ target_link_options(${_target} PRIVATE "LINKER:-undefined,error")
+ elseif(NOT MSVC)
+ target_link_options(${_target} PRIVATE "LINKER:--no-undefined")
+ endif()
set_target_properties(${_target} PROPERTIES
LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
@@ -354,20 +366,20 @@ foreach(_backend cuda opencl vulkan metal rocm)
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_${_backend})
endif()
endforeach()
-if(USE_CPP_RPC)
+if(TVM_USE_CPP_RPC)
add_subdirectory(apps/cpp_rpc)
endif()
-if(USE_CPP_RTVM)
- add_subdirectory(apps/cpp_rtvm)
-endif()
-if(USE_IOS_RPC)
+if(TVM_USE_IOS_RPC)
add_subdirectory(apps/ios_rpc)
endif()
+
+# ######### Installation (parent package only) ##########
+
install(TARGETS tvm_compiler tvm_runtime_extra
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT tvm
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT tvm
RUNTIME DESTINATION ${CMAKE_INSTALL_LIBDIR} COMPONENT tvm)
-if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CUTLASS)
foreach(_target fpA_intB_gemm flash_attn)
tvm_configure_target_library(${_target})
endforeach()
@@ -394,4 +406,3 @@ if(TVM_BUILD_PYTHON_MODULE)
COMPONENT tvm FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp")
endif()
endif()
-find_and_set_linker(${USE_ALTERNATIVE_LINKER})
diff --git a/apps/cpp_rpc/CMakeLists.txt b/apps/cpp_rpc/CMakeLists.txt
index dcc7515572..005794692c 100644
--- a/apps/cpp_rpc/CMakeLists.txt
+++ b/apps/cpp_rpc/CMakeLists.txt
@@ -13,8 +13,9 @@ if(WIN32)
endif()
# Set output to same directory as the other TVM libs
-set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
add_executable(tvm_rpc ${TVM_RPC_SOURCES})
+tvm_configure_target(tvm_rpc)
+set_target_properties(tvm_rpc PROPERTIES RUNTIME_OUTPUT_DIRECTORY
"${CMAKE_BINARY_DIR}")
include(CheckIPOSupported)
check_ipo_supported(RESULT result OUTPUT output)
diff --git a/apps/cpp_rpc/README.md b/apps/cpp_rpc/README.md
index 513d5d34a7..d52a29697e 100644
--- a/apps/cpp_rpc/README.md
+++ b/apps/cpp_rpc/README.md
@@ -19,48 +19,48 @@
This folder contains a simple recipe to make RPC server in c++.
## Usage (Non-Windows)
-- Configure the tvm CMake build with `config.cmake` ensuring that
`USE_CPP_RPC` is set to `ON` in the config.
-- If cross compiling for Android, add the following options to the CMake
config or specify them when invoking CMake:
-```
- # Whether to build the C++ RPC server binary
- set(USE_CPP_RPC ON)
- # Path to the Android NDK CMake toolchain
- set(CMAKE_TOOLCHAIN_FILE
$ENV{ANDROID_NDK}/build/cmake/android.toolchain.cmake)
- # The Android ABI and platform to target
- set(ANDROID_ABI "arm64-v8a")
- set(ANDROID_PLATFORM android-28)
- ```
-- Similarly, if cross compiling for embedded Linux add the following options
to CMake config:
-```
- # Needed to ensure pthread is linked
- set(OS Linux)
- # Path to the desired C++ cross compiler
- set(CMAKE_CXX_COMPILER /path/to/cross/compiler/executable)
-```
-- If you need to build cpp_rpc with OpenCL support, specify variable
`TVM_TIRX_USE_OPENCL` in the config:
- ```
- set(TVM_TIRX_USE_OPENCL ON)
- ```
- In this case [OpenCL-wrapper](../../src/runtime/opencl/opencl_wrapper) or
OpenCL installed to your system will be used.
- When OpenCL-wrapper is used, it will dynamically load OpenCL library on the
device.
- If the device doesn't have OpenCL library on it, then you'll see in the
runtime that OpenCL library cannot be opened.
-
- If linking against a custom device OpenCL library is needed, in the config
specify the path to the OpenCL SDK containing the include/CL headers and lib/
or lib64/libOpenCL.so:
-```
- set(TVM_TIRX_USE_OPENCL /path/to/opencl-sdk)
+
+Configure from the TVM repository root with `cmake -S . -B build
-DTVM_USE_CPP_RPC=ON`.
+For a runtime-only build without LLVM or CUDA, also pass
+`-DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF`.
+For Android cross compilation, pass the toolchain and target options
explicitly:
+
+```bash
+cmake -S . -B build -DTVM_USE_CPP_RPC=ON \
+ -DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF \
+ -DCMAKE_TOOLCHAIN_FILE="$ANDROID_NDK/build/cmake/android.toolchain.cmake" \
+ -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=android-28
```
-- From within the configured tvm build directory, compile `tvm_runtime` and
the `tvm_rpc` server:
+For embedded Linux, configure with the cross compiler:
+
+```bash
+cmake -S . -B build -DTVM_USE_CPP_RPC=ON \
+ -DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF \
+ -DOS=Linux -DCMAKE_CXX_COMPILER=/path/to/cross/compiler/executable
```
- cmake --build $TVM_ROOT/build --target tvm_runtime tvm_rpc -j$(nproc)
+
+For OpenCL support, add `-DTVM_TIRX_USE_OPENCL=ON`. The
+[OpenCL wrapper](../../tirx/src/runtime/opencl/opencl_wrapper) dynamically
loads
+the device's OpenCL library when a system OpenCL SDK is unavailable. The device
+must provide an OpenCL library at runtime. To link against a custom OpenCL SDK,
+pass `-DTVM_TIRX_USE_OPENCL=/path/to/opencl-sdk`; that SDK should contain the
+`include/CL` headers and `lib/` or `lib64/libOpenCL.so`.
+
+Build the runtime and RPC server:
+
+```bash
+cmake --build build --target tvm_runtime tvm_rpc --parallel
```
-- Use `./tvm_rpc server` to start the RPC server
+
+Use `./build/tvm_rpc server` to start the RPC server.
## Usage (Windows)
-- Configure the tvm CMake build with `config.cmake` ensuring that
`USE_CPP_RPC` is set to `ON` in the config.
+
+- Configure the TVM build with `cmake -S . -B build -DTVM_USE_CPP_RPC=ON`.
- Install [LLVM pre-build binaries](https://releases.llvm.org/download.html),
making sure to select the option to add it to the PATH.
- Verify Python 3.6 or newer is installed and in the PATH.
-- Use `<tvm_output_dir>\tvm_rpc.exe` to start the RPC server
+- Use `<tvm_output_dir>\tvm_rpc.exe` to start the RPC server.
## How it works
- The tvm runtime dll is linked along with this executable and when the RPC
server starts it will load the tvm runtime library.
diff --git a/apps/ios_rpc/README.md b/apps/ios_rpc/README.md
index b4db252e91..4f4c669c6b 100644
--- a/apps/ios_rpc/README.md
+++ b/apps/ios_rpc/README.md
@@ -59,8 +59,8 @@ cmake ..
-DCMAKE_OSX_ARCHITECTURES=arm64
-DCMAKE_OSX_DEPLOYMENT_TARGET=14.0
-DCMAKE_BUILD_WITH_INSTALL_NAME_DIR=ON
- -DUSE_IOS_RPC=ON # to enable build iOS RPC application from TVM project tree
- -DUSE_METAL=ON # to enable Metal runtime
+ -DTVM_USE_IOS_RPC=ON # to enable build iOS RPC application from TVM project
tree
+ -DTVM_TIRX_USE_METAL=ON # to enable Metal runtime
cmake --build . --target custom_dso_loader tvm_runtime
```
diff --git a/apps/ios_rpc/tvmrpc/RPCServer.mm b/apps/ios_rpc/tvmrpc/RPCServer.mm
index 3801d49441..389b913f02 100644
--- a/apps/ios_rpc/tvmrpc/RPCServer.mm
+++ b/apps/ios_rpc/tvmrpc/RPCServer.mm
@@ -65,7 +65,7 @@ FEventHandler CreateServerEventHandler(NSOutputStream*
outputStream, std::string
auto event_handler_factory =
tvm::ffi::Function::GetGlobal("rpc.CreateEventDrivenServer");
TVM_FFI_ICHECK(event_handler_factory.has_value())
<< "You are using tvm_runtime module built without RPC support. "
- << "Please rebuild it with USE_RPC flag.";
+ << "Please rebuild it with TVM_USE_RPC flag.";
ffi::Function writer_func([outputStream](ffi::PackedArgs args, ffi::Any* rv)
{
TVMByteArray* data = args[0].ptr<TVMByteArray>();
diff --git a/ci/jenkins/artifacts.py b/ci/jenkins/artifacts.py
index f9a9d97ee7..8af1dd9459 100644
--- a/ci/jenkins/artifacts.py
+++ b/ci/jenkins/artifacts.py
@@ -36,7 +36,7 @@ ARTIFACTS = {
"build/CMakeFiles/rules.ninja",
],
# runtime files
- "tvm_runtime": ["build/lib/libtvm_runtime.so", "build/config.cmake"],
+ "tvm_runtime": ["build/lib/libtvm_runtime.so", "build/CMakeCache.txt"],
# compiler files
"tvm_lib": [
"build/lib/libtvm_compiler.so",
@@ -50,7 +50,7 @@ ARTIFACTS = {
"build/lib/libtvm_runtime_rocm.so",
"build/lib/libtvm_runtime_extra.so",
"build/libtvm_allvisible.so",
- "build/config.cmake",
+ "build/CMakeCache.txt",
],
# gpu related compiler files
"tvm_lib_gpu_extra": [
diff --git a/cmake/config.cmake b/cmake/config.cmake
deleted file mode 100644
index 1a0f4c6161..0000000000
--- a/cmake/config.cmake
+++ /dev/null
@@ -1,307 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-#--------------------------------------------------------------------
-# Template custom CMake configuration for compiling
-#
-# This file is used to override the build options in build.
-# If you want to change the configuration, please use the following
-# steps. Assume you are on the root directory. First copy the this
-# file so that any local changes will be ignored by git
-#
-# $ mkdir build
-# $ cp cmake/config.cmake build
-#
-# Next modify the according entries, and then compile by
-#
-# $ cd build
-# $ cmake ..
-#
-# Then build in parallel with 8 threads
-#
-# $ make -j8
-#--------------------------------------------------------------------
-
-#---------------------------------------------
-# Backend runtimes.
-#---------------------------------------------
-
-# Whether enable CUDA during compile,
-#
-# Possible values:
-# - ON: enable CUDA with CMake's auto search
-# - OFF: disable CUDA
-# - /path/to/cuda: use specific path to CUDA toolkit
-set(TVM_TIRX_USE_CUDA OFF)
-
-# Whether to enable NCCL support:
-# - ON: enable NCCL with CMake's auto search
-# - OFF: disable NCCL
-# - /path/to/nccl: use specific path to nccl
-set(USE_NCCL OFF)
-
-# Whether to enable NVTX support (must have TVM_TIRX_USE_CUDA enabled):
-# - ON: enable NCCL with CMake's auto search
-# - OFF: disable NCCL
-set(USE_NVTX OFF)
-
-# Whether enable ROCM runtime
-#
-# Possible values:
-# - ON: enable ROCM with CMake's auto search
-# - OFF: disable ROCM
-# - /path/to/rocm: use specific path to rocm
-set(TVM_TIRX_USE_ROCM OFF)
-
-# Whether to enable RCCL support:
-# - ON: enable RCCL with CMake's auto search
-# - OFF: disable RCCL
-# - /path/to/rccl: use specific path to rccl
-set(USE_RCCL OFF)
-
-# Whether enable OpenCL runtime
-#
-# Possible values:
-# - ON: enable OpenCL with OpenCL wrapper to remove dependency during build
-# time and trigger dynamic search and loading of OpenCL in runtime
-# - OFF: disable OpenCL
-# - /path/to/opencl-sdk: use specific path to opencl-sdk
-set(TVM_TIRX_USE_OPENCL OFF)
-
-# Whether to allow OPENCL cl_mem access to host
-# cl_mem will be allocated with CL_MEM_ALLOC_HOST_PTR
-# OpenCLWorkspace->GetHostPtr API returns the host accessible pointer
-set(TVM_TIRX_USE_OPENCL_ENABLE_HOST_PTR OFF)
-
-# Whether enable Metal runtime
-set(TVM_TIRX_USE_METAL OFF)
-
-# Whether enable Vulkan runtime
-#
-# Possible values:
-# - ON: enable Vulkan with CMake's auto search
-# - OFF: disable vulkan
-# - /path/to/vulkan-sdk: use specific path to vulkan-sdk
-set(TVM_TIRX_USE_VULKAN OFF)
-
-# Whether to use spirv-tools and SPIRV-Headers from Khronos GitHub or GitLab.
-#
-# Possible values:
-# - OFF: not to use
-# - /path/to/install: path to your khronis spirv-tools and SPIRV-Headers
installation directory
-#
-set(TVM_TIRX_USE_KHRONOS_SPIRV OFF)
-
-# whether enable SPIRV_KHR_DOT_PRODUCT
-set(TVM_TIRX_USE_SPIRV_KHR_INTEGER_DOT_PRODUCT OFF)
-
-# Whether enable RPC runtime
-set(USE_RPC ON)
-
-# Whether to build the C++ RPC server binary
-set(USE_CPP_RPC OFF)
-
-# Whether to build the C++ native runtime tool binary
-set(USE_CPP_RTVM OFF)
-
-# Whether to build the iOS RPC server application
-set(USE_IOS_RPC OFF)
-
-# Whether build with LLVM support
-# Requires LLVM version >= 15
-#
-# Possible values:
-# - ON: enable llvm with CMake's find search
-# - OFF: disable llvm, note this will disable CPU codegen
-# which is needed for most cases
-# - /path/to/llvm-config: enable specific LLVM when multiple llvm-dev is
available.
-set(TVM_TIRX_USE_LLVM OFF)
-
-#---------------------------------------------
-# Contrib libraries
-#---------------------------------------------
-# Whether to build with BYODT software emulated posit custom datatype
-#
-# Possible values:
-# - ON: enable BYODT posit, requires setting UNIVERSAL_PATH
-# - OFF: disable BYODT posit
-#
-# set(UNIVERSAL_PATH /path/to/stillwater-universal) for ON
-set(USE_BYODT_POSIT OFF)
-
-# Whether use BLAS, choices: openblas, atlas, apple
-set(USE_BLAS none)
-
-# Whether to use MKL
-# Possible values:
-# - ON: Enable MKL
-# - /path/to/mkl: mkl root path
-# - OFF: Disable MKL
-# set(USE_MKL /opt/intel/mkl) for UNIX
-# set(USE_MKL ../IntelSWTools/compilers_and_libraries_2018/windows/mkl) for
WIN32
-# set(USE_MKL <path to venv or site-packages directory>) if using `pip install
mkl`
-set(USE_MKL OFF)
-
-# Whether use DNNL library, aka Intel OneDNN:
https://oneapi-src.github.io/oneDNN
-#
-# Now matmul/dense/conv2d supported by -libs=dnnl,
-# and more OP patterns supported in DNNL codegen(json runtime)
-#
-# choices:
-# - ON: Enable DNNL in BYOC and -libs=dnnl, by default using json runtime in
DNNL codegen
-# - JSON: same as above.
-# - C_SRC: use c source runtime in DNNL codegen
-# - path/to/oneDNN:oneDNN root path
-# - OFF: Disable DNNL
-set(USE_DNNL OFF)
-
-# Whether use Intel AMX instructions.
-set(USE_AMX OFF)
-
-# Whether use OpenMP thread pool, choices: gnu, intel
-# Note: "gnu" uses gomp library, "intel" uses iomp5 library
-set(TVM_TIRX_USE_OPENMP OFF)
-
-# Whether use contrib.random in runtime
-set(USE_RANDOM ON)
-
-# Possible values:
-# - ON: enable cuDNN with CMake's auto search in CUDA directory
-# - OFF: disable cuDNN
-# - /path/to/cudnn: use specific path to cuDNN path
-set(USE_CUDNN OFF)
-
-# Whether use cuDNN frontend
-# Possible values:
-# - ON: enable cuDNN frontend
-# - /path/to/cudnn_frontend: use specific path to cuDNN frontend
-# - OFF: disable cuDNN frontend
-set(USE_CUDNN_FRONTEND OFF)
-
-# Whether use cuBLAS
-set(USE_CUBLAS OFF)
-
-# Whether use contrib sort
-set(USE_SORT ON)
-
-# Whether to build with TensorRT codegen or runtime
-# An end-to-end example is available here:
-# docs/how_to/tutorials/bring_your_own_codegen.py.
-#
-# USE_TENSORRT_CODEGEN - Support for compiling a graph where supported
operators are
-# offloaded to TensorRT. OFF/ON
-# USE_TENSORRT_RUNTIME - Support for running TensorRT compiled modules,
requires presence of
-# TensorRT library. OFF/ON/"path/to/TensorRT"
-set(USE_TENSORRT_CODEGEN OFF)
-set(USE_TENSORRT_RUNTIME OFF)
-
-#Whether to use CLML codegen
-set(USE_CLML OFF)
-# USE_CLML_GRAPH_EXECUTOR - CLML SDK PATH or ON or OFF
-set(USE_CLML_GRAPH_EXECUTOR OFF)
-
-# Whether use Thrust
-# Possible values:
-# - ON: enable Thrust with CMake's auto search
-# - OFF: disable Thrust
-# - /path/to/cccl: use specific path to CCCL
-set(USE_THRUST OFF)
-
-# Whether use cuRAND
-set(USE_CURAND OFF)
-
-# Whether to lower Hexagon math intrinsics to QHL calls.
-# The generated code requires QHL runtime wrappers supplied externally.
-set(USE_HEXAGON_QHL OFF)
-
-# Both libtvm_runtime.so and libtvm_runtime_static.a are built by default.
-#
-# Link both static archives with tvm_ffi_static before tvm_runtime_static so
-# FFI type attributes initialize before runtime registrations. Retain both with
-# --whole-archive (or its equivalent), for example:
-# -Wl,--whole-archive -ltvm_ffi_static -ltvm_runtime_static
-Wl,--no-whole-archive
-# The TVM registry relies on global constructors being executed at program
startup.
-# Global constructors alone are not sufficient for the linker to consider a
-# library member to be used, and some of such library members (object files)
may
-# not be included in the final executable. This would make the corresponding
-# runtime functions to be unavailable to the program.
-
-# Caches the build so that building is faster when switching between branches.
-# If you switch branches, build and then encounter a linking error, you may
-# need to regenerate the build tree through "make .." (the cache will
-# still provide significant speedups).
-# Possible values:
-# - AUTO: search for path to ccache, disable if not found.
-# - ON: enable ccache by searching for the path to ccache, report an error if
not found
-# - OFF: disable ccache
-# - /path/to/ccache: use specific path to ccache
-set(USE_CCACHE AUTO)
-
-# Whether to use libbacktrace to supply linenumbers on stack traces.
-# Possible values:
-# - ON: Build from ffi/3rdparty/libbacktrace.
-# - OFF: Don't use libbacktrace.
-# - /path/to/libbacktrace: Looking for the libbacktrace header and static lib
from a user-provided path. Report error if not found.
-set(TVM_FFI_USE_LIBBACKTRACE ON)
-
-# Whether to install a signal handler to print a backtrace on segfault.
-# Need to have TVM_FFI_USE_LIBBACKTRACE enabled.
-set(TVM_FFI_BACKTRACE_ON_SEGFAULT ON)
-
-# Whether to use GoogleTest for C++ unit tests. When enabled, the generated
-# build file (e.g. Makefile) will have a target "cpptest".
-# Possible values:
-# - ON: enable GoogleTest. The package `GTest` will be required for CMake
-# to succeed.
-# - OFF: disable GoogleTest.
-# - AUTO: CMake will attempt to find the GTest package, if found GTest will
-# be enabled, otherwise it will be disabled.
-# Note that CMake will use `find_package` to find GTest. Please use CMake's
-# predefined variables to specify the path to the GTest package if needed.
-set(USE_GTEST AUTO)
-
-# Enable using CUTLASS as a BYOC backend
-# Need to have TVM_TIRX_USE_CUDA=ON
-set(USE_CUTLASS OFF)
-
-# Whether to enable FlashInfer or not.
-set(USE_FLASHINFER OFF)
-# Options for FlashInfer kernel compilation.
-set(FLASHINFER_ENABLE_FP8 OFF)
-set(FLASHINFER_ENABLE_BF16 OFF)
-set(FLASHINFER_GEN_GROUP_SIZES 1 4 6 8)
-set(FLASHINFER_GEN_PAGE_SIZES 16)
-set(FLASHINFER_GEN_HEAD_DIMS 128)
-set(FLASHINFER_GEN_KV_LAYOUTS 0 1)
-set(FLASHINFER_GEN_POS_ENCODING_MODES 0 1)
-set(FLASHINFER_GEN_ALLOW_FP16_QK_REDUCTIONS "false")
-set(FLASHINFER_GEN_CASUALS "false" "true")
-
-# Enable to show a summary of TVM options
-set(SUMMARIZE OFF)
-
-# Set custom Alloc Alignment for device allocated memory ndarray points to
-set(USE_KALLOC_ALIGNMENT 64)
-
-# Set Windows Visual Studio default Architecture (equivalent to -A x64)
-SET(CMAKE_VS_PLATFORM_NAME_DEFAULT "x64")
-
-# Set Windows Visual Studio default host (equivalent to -Thost=x64)
-SET(CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE "x64")
-
-# Enable Qualcomm OpenCL extension support
-set(TVM_TIRX_USE_OPENCL_EXTN_QCOM OFF)
diff --git a/cmake/modules/RuntimeExtra.cmake b/cmake/modules/RuntimeExtra.cmake
index e3057ebe0b..6f7a63682e 100644
--- a/cmake/modules/RuntimeExtra.cmake
+++ b/cmake/modules/RuntimeExtra.cmake
@@ -17,39 +17,41 @@
# Assemble the runtime-extra target declared before the backend modules.
# Disco core sources.
-tvm_file_glob(GLOB _disco_core_srcs src/runtime/extra/disco/*.cc)
+file(GLOB _disco_core_srcs CONFIGURE_DEPENDS src/runtime/extra/disco/*.cc)
add_library(tvm_disco_objs OBJECT ${_disco_core_srcs})
+tvm_configure_target(tvm_disco_objs)
target_link_libraries(tvm_disco_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_disco_objs)
# Distributed disco.
-tvm_file_glob(GLOB _disco_dist_srcs src/runtime/extra/disco/distributed/*.cc)
+file(GLOB _disco_dist_srcs CONFIGURE_DEPENDS
src/runtime/extra/disco/distributed/*.cc)
add_library(tvm_disco_distributed_objs OBJECT ${_disco_dist_srcs})
+tvm_configure_target(tvm_disco_distributed_objs)
target_link_libraries(tvm_disco_distributed_objs PRIVATE
tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_disco_distributed_objs)
# NCCL / cuda_ipc — requires CUDA + NCCL.
-if(TVM_TIRX_USE_CUDA AND USE_NCCL)
- find_nccl(${USE_NCCL})
- include_directories(SYSTEM ${NCCL_INCLUDE_DIR})
- tvm_file_glob(GLOB _nccl_srcs src/runtime/extra/disco/nccl/*.cc
src/runtime/extra/disco/cuda_ipc/*.cc 3rdparty/tensorrt_llm/*.cu)
- set_source_files_properties(src/runtime/extra/disco/nccl/nccl.cc PROPERTIES
COMPILE_DEFINITIONS "TVM_NCCL_RCCL_SWITCH=0")
+if(TVM_TIRX_USE_CUDA AND TVM_USE_NCCL)
+ find_nccl(${TVM_USE_NCCL})
+ file(GLOB _nccl_srcs CONFIGURE_DEPENDS src/runtime/extra/disco/nccl/*.cc
src/runtime/extra/disco/cuda_ipc/*.cc 3rdparty/tensorrt_llm/*.cu)
add_library(tvm_nccl_objs OBJECT ${_nccl_srcs})
- target_link_libraries(tvm_nccl_objs PRIVATE tvm_runtime_extra_defs)
+ tvm_configure_target(tvm_nccl_objs)
+ target_compile_definitions(tvm_nccl_objs PRIVATE TVM_NCCL_RCCL_SWITCH=0)
+ target_link_libraries(tvm_nccl_objs PRIVATE tvm_runtime_extra_defs nccl)
find_library(LIBRT rt)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_nccl_objs nccl ${LIBRT})
endif()
# NVSHMEM.
-if(TVM_TIRX_USE_CUDA AND USE_NVSHMEM)
- find_nvshmem(${USE_NVSHMEM})
+if(TVM_TIRX_USE_CUDA AND TVM_USE_NVSHMEM)
+ find_nvshmem(${TVM_USE_NVSHMEM})
if(NOT NVSHMEM_FOUND)
- message(FATAL_ERROR "Cannot find NVSHMEM, USE_NVSHMEM=" ${USE_NVSHMEM})
+ message(FATAL_ERROR "Cannot find NVSHMEM, TVM_USE_NVSHMEM="
${TVM_USE_NVSHMEM})
endif()
- set(CMAKE_CUDA_SEPARABLE_COMPILATION ON)
- set(CMAKE_POSITION_INDEPENDENT_CODE ON)
- tvm_file_glob(GLOB _nvshmem_srcs src/runtime/extra/contrib/nvshmem/*.cc
src/runtime/extra/contrib/nvshmem/*.cu)
+ file(GLOB _nvshmem_srcs CONFIGURE_DEPENDS
src/runtime/extra/contrib/nvshmem/*.cc src/runtime/extra/contrib/nvshmem/*.cu)
add_library(tvm_nvshmem_objs OBJECT ${_nvshmem_srcs})
+ tvm_configure_target(tvm_nvshmem_objs)
+ set_target_properties(tvm_nvshmem_objs PROPERTIES CUDA_SEPARABLE_COMPILATION
ON)
target_link_libraries(tvm_nvshmem_objs PRIVATE tvm_runtime_extra_defs)
target_include_directories(tvm_nvshmem_objs PUBLIC ${NVSHMEM_INCLUDE_DIR})
# CUDA 13 moved libcu++ under include/cccl. NVSHMEM's headers include
@@ -66,13 +68,13 @@ if(TVM_TIRX_USE_CUDA AND USE_NVSHMEM)
endif()
# RCCL.
-if(TVM_TIRX_USE_ROCM AND USE_RCCL)
- find_rccl(${USE_RCCL})
- include_directories(SYSTEM ${RCCL_INCLUDE_DIR})
- tvm_file_glob(GLOB _rccl_srcs src/runtime/extra/disco/nccl/*.cc)
- set_source_files_properties(src/runtime/extra/disco/nccl/nccl.cc PROPERTIES
COMPILE_DEFINITIONS "TVM_NCCL_RCCL_SWITCH=1")
+if(TVM_TIRX_USE_ROCM AND TVM_USE_RCCL)
+ find_rccl(${TVM_USE_RCCL})
+ file(GLOB _rccl_srcs CONFIGURE_DEPENDS src/runtime/extra/disco/nccl/*.cc)
add_library(tvm_rccl_objs OBJECT ${_rccl_srcs})
- target_link_libraries(tvm_rccl_objs PRIVATE tvm_runtime_extra_defs)
+ tvm_configure_target(tvm_rccl_objs)
+ target_compile_definitions(tvm_rccl_objs PRIVATE TVM_NCCL_RCCL_SWITCH=1)
+ target_link_libraries(tvm_rccl_objs PRIVATE tvm_runtime_extra_defs rccl)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_rccl_objs rccl)
endif()
@@ -89,14 +91,7 @@ if(TVM_TIRX_USE_ROCM)
endif()
# CUTLASS fpA_intB_gemm and flash_attn are separate shared libs.
-if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CUTLASS)
target_link_libraries(tvm_runtime_extra PRIVATE fpA_intB_gemm
fpA_intB_gemm_tvm)
target_link_libraries(tvm_runtime_extra PRIVATE -Wl,--no-as-needed
flash_attn)
endif()
-
-if(TVM_VISIBILITY_FLAG)
- set_property(TARGET tvm_runtime_extra APPEND PROPERTY LINK_OPTIONS
"${TVM_VISIBILITY_FLAG}")
-endif()
-
-# The root registers the package-owned installation alongside tvm_compiler.
-tvm_configure_target_library(tvm_runtime_extra)
diff --git a/cmake/modules/contrib/AMX.cmake b/cmake/modules/contrib/AMX.cmake
index 553171400d..3cdd89d21a 100644
--- a/cmake/modules/contrib/AMX.cmake
+++ b/cmake/modules/contrib/AMX.cmake
@@ -15,9 +15,10 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_AMX)
- file(GLOB AMX_RUNTIME_CONFIG src/runtime/extra/contrib/amx/amx_config.cc)
+if(TVM_USE_AMX)
+ file(GLOB AMX_RUNTIME_CONFIG CONFIGURE_DEPENDS
src/runtime/extra/contrib/amx/amx_config.cc)
add_library(tvm_amx_objs OBJECT ${AMX_RUNTIME_CONFIG})
+ tvm_configure_target(tvm_amx_objs)
target_link_libraries(tvm_amx_objs PRIVATE tvm_runtime_extra_defs)
target_compile_options(tvm_amx_objs PRIVATE -march=sapphirerapids)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_amx_objs)
diff --git a/cmake/modules/contrib/BLAS.cmake b/cmake/modules/contrib/BLAS.cmake
index 710ce3ed2a..0f2970781c 100644
--- a/cmake/modules/contrib/BLAS.cmake
+++ b/cmake/modules/contrib/BLAS.cmake
@@ -15,57 +15,58 @@
# specific language governing permissions and limitations
# under the License.
-if(DEFINED USE_MKL_PATH)
- message(FATAL_ERROR "USE_MKL_PATH has been removed. Set USE_MKL to the MKL
installation path instead.")
-endif()
-
-if(USE_BLAS STREQUAL "openblas")
+if(TVM_USE_BLAS STREQUAL "openblas")
find_library(BLAS_LIBRARY openblas)
add_library(tvm_blas_objs OBJECT src/runtime/extra/contrib/cblas/cblas.cc)
+ tvm_configure_target(tvm_blas_objs)
target_link_libraries(tvm_blas_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_blas_objs
${BLAS_LIBRARY})
message(STATUS "Using BLAS library " ${BLAS_LIBRARY})
find_path(BLAS_INCLUDE_DIR cblas.h PATH_SUFFIXES openblas)
if(BLAS_INCLUDE_DIR)
message(STATUS "Using BLAS header in " ${BLAS_INCLUDE_DIR})
- include_directories(SYSTEM ${BLAS_INCLUDE_DIR})
+ target_include_directories(tvm_blas_objs SYSTEM PRIVATE
${BLAS_INCLUDE_DIR})
endif()
-elseif(USE_BLAS STREQUAL "atlas" OR USE_BLAS STREQUAL "blas")
+elseif(TVM_USE_BLAS STREQUAL "atlas" OR TVM_USE_BLAS STREQUAL "blas")
find_library(BLAS_LIBRARY cblas)
add_library(tvm_blas_objs OBJECT src/runtime/extra/contrib/cblas/cblas.cc)
+ tvm_configure_target(tvm_blas_objs)
target_link_libraries(tvm_blas_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_blas_objs
${BLAS_LIBRARY})
message(STATUS "Use BLAS library " ${BLAS_LIBRARY})
-elseif(USE_BLAS STREQUAL "apple")
+elseif(TVM_USE_BLAS STREQUAL "apple")
find_library(BLAS_LIBRARY Accelerate)
- include_directories(SYSTEM
${BLAS_LIBRARY}/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/)
add_library(tvm_blas_objs OBJECT src/runtime/extra/contrib/cblas/cblas.cc)
+ target_include_directories(tvm_blas_objs SYSTEM PRIVATE
+
${BLAS_LIBRARY}/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/)
+ tvm_configure_target(tvm_blas_objs)
target_link_libraries(tvm_blas_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_blas_objs
${BLAS_LIBRARY})
message(STATUS "Use BLAS library " ${BLAS_LIBRARY})
-elseif(USE_BLAS STREQUAL "mkl")
- message(FATAL_ERROR "USE_BLAS=mkl has been removed. Use USE_MKL=ON instead.")
-elseif(USE_BLAS STREQUAL "none")
+elseif(TVM_USE_BLAS STREQUAL "mkl")
+ message(FATAL_ERROR "TVM_USE_BLAS=mkl has been removed. Use TVM_USE_MKL=ON
instead.")
+elseif(TVM_USE_BLAS STREQUAL "none")
# pass
else()
- message(FATAL_ERROR "Invalid option: USE_BLAS=" ${USE_BLAS})
+ message(FATAL_ERROR "Invalid option: TVM_USE_BLAS=" ${TVM_USE_BLAS})
endif()
-if(USE_MKL)
- if(NOT IS_DIRECTORY ${USE_MKL})
- set(USE_MKL /opt/intel/mkl)
+if(TVM_USE_MKL)
+ if(NOT IS_DIRECTORY ${TVM_USE_MKL})
+ set(TVM_USE_MKL /opt/intel/mkl)
endif()
if(APPLE)
- find_library(BLAS_LIBRARY_MKL NAMES mklml mkl_rt HINTS ${USE_MKL}/lib/
${USE_MKL}/lib/intel64)
+ find_library(BLAS_LIBRARY_MKL NAMES mklml mkl_rt HINTS ${TVM_USE_MKL}/lib/
${TVM_USE_MKL}/lib/intel64)
elseif(UNIX)
- find_library(BLAS_LIBRARY_MKL NAMES mkl_rt mklml_gnu HINTS ${USE_MKL}/lib/
${USE_MKL}/lib/intel64)
+ find_library(BLAS_LIBRARY_MKL NAMES mkl_rt mklml_gnu HINTS
${TVM_USE_MKL}/lib/ ${TVM_USE_MKL}/lib/intel64)
elseif(MSVC)
- find_library(BLAS_LIBRARY_MKL NAMES mkl_rt HINTS ${USE_MKL}/lib/
${USE_MKL}/lib/intel64_win)
+ find_library(BLAS_LIBRARY_MKL NAMES mkl_rt HINTS ${TVM_USE_MKL}/lib/
${TVM_USE_MKL}/lib/intel64_win)
endif()
- include_directories(SYSTEM ${USE_MKL}/include)
add_library(tvm_mkl_objs OBJECT src/runtime/extra/contrib/cblas/mkl.cc)
+ tvm_configure_target(tvm_mkl_objs)
+ target_include_directories(tvm_mkl_objs SYSTEM PRIVATE
${TVM_USE_MKL}/include)
target_link_libraries(tvm_mkl_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_mkl_objs
${BLAS_LIBRARY_MKL})
- add_definitions(-DUSE_MKL_BLAS=1)
+ target_compile_definitions(tvm_mkl_objs PRIVATE USE_MKL_BLAS=1)
message(STATUS "Use MKL library " ${BLAS_LIBRARY_MKL})
endif()
diff --git a/cmake/modules/contrib/CLML.cmake b/cmake/modules/contrib/CLML.cmake
index 73ab85db09..4dec606015 100644
--- a/cmake/modules/contrib/CLML.cmake
+++ b/cmake/modules/contrib/CLML.cmake
@@ -15,9 +15,9 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_CLML)
- file(GLOB CLML_RELAX_CONTRIB_SRC src/relax/backend/contrib/clml/*.cc)
- file(GLOB CLML_RUNTIME_MODULE
src/runtime/extra/contrib/clml/clml_runtime.cc)
+if(TVM_USE_CLML)
+ file(GLOB CLML_RELAX_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/clml/*.cc)
+ file(GLOB CLML_RUNTIME_MODULE CONFIGURE_DEPENDS
src/runtime/extra/contrib/clml/clml_runtime.cc)
if(TARGET tvm_runtime_opencl)
get_target_property(_clml_opencl_headers tvm_runtime_opencl
INTERFACE_INCLUDE_DIRECTORIES)
endif()
@@ -26,16 +26,17 @@ if(USE_CLML)
HINTS "${TVM_OPENCL_HEADERS_ROOT}" ENV OPENCL_SDK
PATH_SUFFIXES include REQUIRED)
endif()
- include_directories(SYSTEM ${_clml_opencl_headers})
list(APPEND COMPILER_SRCS ${CLML_RELAX_CONTRIB_SRC})
- if(NOT USE_CLML_GRAPH_EXECUTOR)
+ if(NOT TVM_USE_CLML_GRAPH_EXECUTOR)
add_library(tvm_clml_objs OBJECT ${CLML_RUNTIME_MODULE})
+ tvm_configure_target(tvm_clml_objs)
+ target_include_directories(tvm_clml_objs SYSTEM PRIVATE
${_clml_opencl_headers})
target_link_libraries(tvm_clml_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_clml_objs)
endif()
- message(STATUS "Build with CLML support : " ${USE_CLML})
- if(NOT USE_CLML STREQUAL "ON")
- set(CLML_VERSION_HEADER "${USE_CLML}/CL/cl_qcom_ml_ops.h")
+ message(STATUS "Build with CLML support : " ${TVM_USE_CLML})
+ if(NOT TVM_USE_CLML STREQUAL "ON")
+ set(CLML_VERSION_HEADER "${TVM_USE_CLML}/CL/cl_qcom_ml_ops.h")
if(EXISTS ${CLML_VERSION_HEADER})
file(READ ${CLML_VERSION_HEADER} ver)
string(REGEX MATCH "CL_QCOM_ML_OPS_H_MAJOR_VERSION ([0-9]*)" _
${ver})
@@ -46,25 +47,24 @@ if(USE_CLML)
else()
set(CLML_VERSION_MAJOR "4")
endif()
- add_definitions(-DTVM_CLML_VERSION=${CLML_VERSION_MAJOR})
+ target_compile_definitions(tvm_compiler PRIVATE
TVM_CLML_VERSION=${CLML_VERSION_MAJOR})
message(STATUS "CLML SDK Version :" ${CLML_VERSION_MAJOR})
else()
set(CLML_VERSION_MAJOR "4")
endif()
-if(USE_CLML_GRAPH_EXECUTOR)
+if(TVM_USE_CLML_GRAPH_EXECUTOR)
set(CLML_PATH ${CMAKE_CURRENT_SOURCE_DIR}/clml)
# Detect custom CLML path.
- if(NOT USE_CLML_GRAPH_EXECUTOR STREQUAL "ON")
- set(CLML_PATH ${USE_CLML_GRAPH_EXECUTOR})
+ if(NOT TVM_USE_CLML_GRAPH_EXECUTOR STREQUAL "ON")
+ set(CLML_PATH ${TVM_USE_CLML_GRAPH_EXECUTOR})
endif()
- file(GLOB CLML_CONTRIB_SRC src/runtime/extra/contrib/clml/*)
+ file(GLOB CLML_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/clml/*)
# CMake needs to find clml library, include and support directories
# in the path specified by CLML_PATH.
set(CLML_INCLUDE_DIRS ${CLML_PATH}/include ${CLML_PATH})
- include_directories(${CLML_INCLUDE_DIRS})
find_library(EXTERN_CLML_COMPUTE_LIB
NAMES OpenCL libOpenCL
HINTS "${CLML_PATH}" "${CLML_PATH}/lib64" "${CLML_PATH}/lib"
@@ -79,13 +79,15 @@ if(USE_CLML_GRAPH_EXECUTOR)
endif()
endif()
add_library(tvm_clml_objs OBJECT ${CLML_CONTRIB_SRC})
+ tvm_configure_target(tvm_clml_objs)
target_link_libraries(tvm_clml_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_clml_objs
${EXTERN_CLML_COMPUTE_LIB})
message(STATUS "Build with CLML graph runtime support: "
${EXTERN_CLML_COMPUTE_LIB})
- # Set flag to detect CLML graph runtime support.
- add_definitions(-DTVM_GRAPH_EXECUTOR_CLML)
+ target_include_directories(tvm_clml_objs PRIVATE ${CLML_INCLUDE_DIRS})
+ target_compile_definitions(tvm_clml_objs PRIVATE TVM_GRAPH_EXECUTOR_CLML)
+ target_compile_definitions(tvm_compiler PRIVATE TVM_GRAPH_EXECUTOR_CLML)
message(STATUS "Enable OpenCL as fallback to CLML")
set(TVM_TIRX_USE_OPENCL ${CLML_PATH})
diff --git a/cmake/modules/contrib/CUDA.cmake b/cmake/modules/contrib/CUDA.cmake
index 91994d337c..6b454ab712 100644
--- a/cmake/modules/contrib/CUDA.cmake
+++ b/cmake/modules/contrib/CUDA.cmake
@@ -18,67 +18,81 @@
# Contrib sources gated by TVM_TIRX_USE_CUDA go into libtvm_runtime_extra.
# See the RuntimeExtra assembly block in CMakeLists.txt.
-if(TVM_TIRX_USE_CUDA AND USE_CUDNN)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CUDNN)
message(STATUS "Build with cuDNN support")
- include_directories(SYSTEM ${CUDA_CUDNN_INCLUDE_DIRS})
- tvm_file_glob(GLOB CUDNN_RELAX_CONTRIB_SRC
src/relax/backend/contrib/cudnn/*.cc)
+ file(GLOB CUDNN_RELAX_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/cudnn/*.cc)
list(APPEND COMPILER_SRCS ${CUDNN_RELAX_CONTRIB_SRC})
- tvm_file_glob(GLOB CONTRIB_CUDNN_SRCS src/runtime/extra/contrib/cudnn/*.cc)
+ file(GLOB CONTRIB_CUDNN_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/cudnn/*.cc)
add_library(tvm_cudnn_objs OBJECT ${CONTRIB_CUDNN_SRCS})
+ tvm_configure_target(tvm_cudnn_objs)
+ target_include_directories(tvm_cudnn_objs SYSTEM PRIVATE
${CUDA_CUDNN_INCLUDE_DIRS})
target_link_libraries(tvm_cudnn_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_cudnn_objs
${CUDA_CUDNN_LIBRARY})
-endif(TVM_TIRX_USE_CUDA AND USE_CUDNN)
+endif(TVM_TIRX_USE_CUDA AND TVM_USE_CUDNN)
-if(TVM_TIRX_USE_CUDA AND USE_CUDNN_FRONTEND)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CUDNN_FRONTEND)
message(STATUS "Build with cuDNN Frontend support")
- if(IS_DIRECTORY ${USE_CUDNN_FRONTEND})
- find_file(CUDNN_FRONTEND_HEADER cudnn_frontend.h HINTS
${USE_CUDNN_FRONTEND}/include)
- include_directories(SYSTEM ${USE_CUDNN_FRONTEND}/include)
+ if(IS_DIRECTORY ${TVM_USE_CUDNN_FRONTEND})
+ find_file(CUDNN_FRONTEND_HEADER cudnn_frontend.h HINTS
${TVM_USE_CUDNN_FRONTEND}/include)
else()
find_file(CUDNN_FRONTEND_HEADER cudnn_frontend.h)
endif()
if(NOT CUDNN_FRONTEND_HEADER)
- message(FATAL_ERROR "Cannot find cudnn_frontend.h, please set
USE_CUDNN_FRONTEND to the path of the cuDNN frontend header")
+ message(FATAL_ERROR "Cannot find cudnn_frontend.h, please set
TVM_USE_CUDNN_FRONTEND to the path of the cuDNN frontend header")
+ endif()
+ file(GLOB CONTRIB_CUDNN_FRONTEND_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/cudnn/cudnn_frontend/*.cc)
+ get_filename_component(CUDNN_FRONTEND_INCLUDE_DIR ${CUDNN_FRONTEND_HEADER}
DIRECTORY)
+ if(TARGET tvm_cudnn_objs)
+ target_include_directories(tvm_cudnn_objs SYSTEM PRIVATE
${CUDNN_FRONTEND_INCLUDE_DIR})
+ target_compile_definitions(tvm_cudnn_objs PRIVATE TVM_USE_CUDNN_FRONTEND=1)
endif()
- tvm_file_glob(GLOB CONTRIB_CUDNN_FRONTEND_SRCS
src/runtime/extra/contrib/cudnn/cudnn_frontend/*.cc)
- set_source_files_properties(${CONTRIB_CUDNN_SRCS} PROPERTIES
COMPILE_DEFINITIONS TVM_USE_CUDNN_FRONTEND=1)
add_library(tvm_cudnn_frontend_objs OBJECT ${CONTRIB_CUDNN_FRONTEND_SRCS})
+ tvm_configure_target(tvm_cudnn_frontend_objs)
+ target_include_directories(tvm_cudnn_frontend_objs SYSTEM PRIVATE
+ ${CUDNN_FRONTEND_INCLUDE_DIR} ${CUDA_CUDNN_INCLUDE_DIRS})
target_link_libraries(tvm_cudnn_frontend_objs PRIVATE tvm_runtime_extra_defs)
- target_link_libraries(tvm_runtime_extra PRIVATE tvm_cudnn_frontend_objs)
-endif(TVM_TIRX_USE_CUDA AND USE_CUDNN_FRONTEND)
+ target_link_libraries(tvm_runtime_extra PRIVATE tvm_cudnn_frontend_objs
${CUDA_CUDNN_LIBRARY})
+endif(TVM_TIRX_USE_CUDA AND TVM_USE_CUDNN_FRONTEND)
-if(TVM_TIRX_USE_CUDA AND USE_CUBLAS)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CUBLAS)
message(STATUS "Build with cuBLAS support")
- tvm_file_glob(GLOB CUBLAS_CONTRIB_SRC src/relax/backend/contrib/cublas/*.cc)
+ file(GLOB CUBLAS_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/cublas/*.cc)
list(APPEND COMPILER_SRCS ${CUBLAS_CONTRIB_SRC})
- tvm_file_glob(GLOB CONTRIB_CUBLAS_SRCS src/runtime/extra/contrib/cublas/*.cc)
+ file(GLOB CONTRIB_CUBLAS_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/cublas/*.cc)
add_library(tvm_cublas_objs OBJECT ${CONTRIB_CUBLAS_SRCS})
+ tvm_configure_target(tvm_cublas_objs)
target_link_libraries(tvm_cublas_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_cublas_objs
${CUDA_CUBLAS_LIBRARY})
if(NOT CUDA_CUBLASLT_LIBRARY STREQUAL "CUDA_CUBLASLT_LIBRARY-NOTFOUND")
target_link_libraries(tvm_runtime_extra PRIVATE ${CUDA_CUBLASLT_LIBRARY})
endif()
-endif(TVM_TIRX_USE_CUDA AND USE_CUBLAS)
+endif(TVM_TIRX_USE_CUDA AND TVM_USE_CUBLAS)
-if(TVM_TIRX_USE_CUDA AND USE_THRUST)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_THRUST)
message(STATUS "Build with Thrust support")
- tvm_file_glob(GLOB CONTRIB_THRUST_SRC src/runtime/extra/contrib/thrust/*.cu)
+ file(GLOB CONTRIB_THRUST_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/thrust/*.cu)
add_library(tvm_thrust_objs OBJECT ${CONTRIB_THRUST_SRC})
+ tvm_configure_target(tvm_thrust_objs)
target_link_libraries(tvm_thrust_objs PRIVATE tvm_runtime_extra_defs)
target_compile_options(tvm_thrust_objs PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:--expt-extended-lambda>)
- if(NOT USE_THRUST MATCHES ${IS_TRUE_PATTERN})
- find_package(CCCL REQUIRED COMPONENTS Thrust)
+ if(NOT TVM_USE_THRUST MATCHES ${IS_TRUE_PATTERN})
+ set(CCCL_DIR "${TVM_USE_THRUST}")
+ find_package(CCCL REQUIRED COMPONENTS Thrust
+ HINTS "${TVM_USE_THRUST}"
+ PATH_SUFFIXES lib/cmake/cccl lib64/cmake/cccl
+ NO_DEFAULT_PATH)
target_link_libraries(tvm_thrust_objs PRIVATE CCCL::Thrust)
endif()
target_link_libraries(tvm_runtime_extra PRIVATE tvm_thrust_objs)
-endif(TVM_TIRX_USE_CUDA AND USE_THRUST)
+endif(TVM_TIRX_USE_CUDA AND TVM_USE_THRUST)
-if(TVM_TIRX_USE_CUDA AND USE_CURAND)
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CURAND)
message(STATUS "Build with cuRAND support")
message(STATUS "${CUDA_CURAND_LIBRARY}")
- tvm_file_glob(GLOB CONTRIB_CURAND_SRC_CC
src/runtime/extra/contrib/curand/*.cc)
- tvm_file_glob(GLOB CONTRIB_CURAND_SRC_CU
src/runtime/extra/contrib/curand/*.cu)
+ file(GLOB CONTRIB_CURAND_SRC_CC CONFIGURE_DEPENDS
src/runtime/extra/contrib/curand/*.cc)
+ file(GLOB CONTRIB_CURAND_SRC_CU CONFIGURE_DEPENDS
src/runtime/extra/contrib/curand/*.cu)
add_library(tvm_curand_objs OBJECT ${CONTRIB_CURAND_SRC_CC}
${CONTRIB_CURAND_SRC_CU})
+ tvm_configure_target(tvm_curand_objs)
target_link_libraries(tvm_curand_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_curand_objs
${CUDA_CURAND_LIBRARY})
-endif(TVM_TIRX_USE_CUDA AND USE_CURAND)
+endif(TVM_TIRX_USE_CUDA AND TVM_USE_CURAND)
diff --git a/cmake/modules/contrib/CUTLASS.cmake
b/cmake/modules/contrib/CUTLASS.cmake
index 1c287f36cb..c0989ec841 100644
--- a/cmake/modules/contrib/CUTLASS.cmake
+++ b/cmake/modules/contrib/CUTLASS.cmake
@@ -15,9 +15,8 @@
# specific language governing permissions and limitations
# under the License.
-if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
- tvm_file_glob(GLOB CUTLASS_CONTRIB_SRC
- src/relax/backend/contrib/cutlass/*.cc
+if(TVM_TIRX_USE_CUDA AND TVM_USE_CUTLASS)
+ file(GLOB CUTLASS_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/cutlass/*.cc
)
list(APPEND COMPILER_SRCS ${CUTLASS_CONTRIB_SRC})
@@ -26,6 +25,8 @@ if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
### Build cutlass runtime objects for fpA_intB_gemm using its cutlass
submodule
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm)
+ tvm_configure_target(fpA_intB_gemm KEEP_SYMBOLS)
+ tvm_configure_target(fpA_intB_gemm_tvm)
target_include_directories(fpA_intB_gemm PRIVATE
${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm
${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm/cutlass/include
@@ -35,6 +36,7 @@ if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
set(CUTLASS_FPA_INTB_RUNTIME_SRCS "")
list(APPEND CUTLASS_FPA_INTB_RUNTIME_SRCS
src/runtime/extra/contrib/cutlass/weight_preprocess.cc)
add_library(fpA_intB_cutlass_objs OBJECT ${CUTLASS_FPA_INTB_RUNTIME_SRCS})
+ tvm_configure_target(fpA_intB_cutlass_objs)
target_link_libraries(fpA_intB_cutlass_objs PRIVATE tvm_runtime_extra_defs)
target_include_directories(fpA_intB_cutlass_objs PRIVATE
${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm
@@ -44,6 +46,7 @@ if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
### Build cutlass runtime objects for flash attention
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/libflash_attn)
+ tvm_configure_target(flash_attn KEEP_SYMBOLS)
target_include_directories(flash_attn PRIVATE
${PROJECT_SOURCE_DIR}/3rdparty/libflash_attn
${PROJECT_SOURCE_DIR}/3rdparty/libflash_attn/cutlass/include
@@ -66,6 +69,7 @@ if(TVM_TIRX_USE_CUDA AND USE_CUTLASS)
endif()
if(TVM_CUTLASS_RUNTIME_SRCS)
add_library(tvm_cutlass_objs OBJECT ${TVM_CUTLASS_RUNTIME_SRCS})
+ tvm_configure_target(tvm_cutlass_objs)
target_compile_options(tvm_cutlass_objs PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:-lineinfo --expt-relaxed-constexpr>)
target_include_directories(tvm_cutlass_objs PRIVATE
${CUTLASS_DIR}/include
diff --git a/cmake/modules/contrib/CoreML.cmake
b/cmake/modules/contrib/CoreML.cmake
index fdadf4f3d6..0cb9187c79 100644
--- a/cmake/modules/contrib/CoreML.cmake
+++ b/cmake/modules/contrib/CoreML.cmake
@@ -15,12 +15,13 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_COREML)
+if(TVM_USE_COREML)
message(STATUS "Build with contrib.coreml")
find_library(FOUNDATION_LIB Foundation)
find_library(COREML_LIB Coreml)
- tvm_file_glob(GLOB COREML_CONTRIB_SRC src/runtime/extra/contrib/coreml/*.mm)
+ file(GLOB COREML_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/coreml/*.mm)
add_library(tvm_coreml_objs OBJECT ${COREML_CONTRIB_SRC})
+ tvm_configure_target(tvm_coreml_objs)
target_link_libraries(tvm_coreml_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_coreml_objs
${FOUNDATION_LIB} ${COREML_LIB})
-endif(USE_COREML)
+endif(TVM_USE_COREML)
diff --git a/cmake/modules/contrib/DNNL.cmake b/cmake/modules/contrib/DNNL.cmake
index 087e0e0cc9..80c8d99324 100644
--- a/cmake/modules/contrib/DNNL.cmake
+++ b/cmake/modules/contrib/DNNL.cmake
@@ -15,49 +15,53 @@
# specific language governing permissions and limitations
# under the License.
-if(IS_DIRECTORY ${USE_DNNL})
- find_library(EXTERN_LIBRARY_DNNL NAMES dnnl HINTS ${USE_DNNL}/lib/)
+if(IS_DIRECTORY ${TVM_USE_DNNL})
+ find_library(EXTERN_LIBRARY_DNNL NAMES dnnl HINTS ${TVM_USE_DNNL}/lib/)
if(EXTERN_LIBRARY_DNNL STREQUAL "EXTERN_LIBRARY_DNNL-NOTFOUND")
- message(WARNING "Cannot find DNNL library at ${USE_DNNL}.")
+ message(WARNING "Cannot find DNNL library at ${TVM_USE_DNNL}.")
else()
- add_definitions(-DUSE_JSON_RUNTIME=1)
- tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/relax/backend/contrib/dnnl/*.cc)
+ file(GLOB DNNL_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/dnnl/*.cc)
list(APPEND COMPILER_SRCS ${DNNL_CONTRIB_SRC})
- tvm_file_glob(GLOB DNNL_CONTRIB_SRC
src/runtime/extra/contrib/dnnl/dnnl_json_runtime.cc
+ file(GLOB DNNL_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/dnnl/dnnl_json_runtime.cc
src/runtime/extra/contrib/dnnl/dnnl_utils.cc
src/runtime/extra/contrib/dnnl/dnnl.cc
src/runtime/extra/contrib/cblas/dnnl_blas.cc)
add_library(tvm_dnnl_objs OBJECT ${DNNL_CONTRIB_SRC})
+ tvm_configure_target(tvm_dnnl_objs)
+ target_compile_definitions(tvm_dnnl_objs PRIVATE USE_JSON_RUNTIME=1)
+ target_include_directories(tvm_dnnl_objs SYSTEM PRIVATE
${TVM_USE_DNNL}/include)
target_link_libraries(tvm_dnnl_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_dnnl_objs
${EXTERN_LIBRARY_DNNL})
message(STATUS "Build with DNNL JSON runtime: " ${EXTERN_LIBRARY_DNNL})
endif()
-elseif((USE_DNNL STREQUAL "ON") OR (USE_DNNL STREQUAL "JSON"))
- add_definitions(-DUSE_JSON_RUNTIME=1)
- tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/relax/backend/contrib/dnnl/*.cc)
+elseif((TVM_USE_DNNL STREQUAL "ON") OR (TVM_USE_DNNL STREQUAL "JSON"))
+ file(GLOB DNNL_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/dnnl/*.cc)
list(APPEND COMPILER_SRCS ${DNNL_CONTRIB_SRC})
find_library(EXTERN_LIBRARY_DNNL dnnl)
- tvm_file_glob(GLOB DNNL_CONTRIB_SRC
src/runtime/extra/contrib/dnnl/dnnl_json_runtime.cc
+ file(GLOB DNNL_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/dnnl/dnnl_json_runtime.cc
src/runtime/extra/contrib/dnnl/dnnl_utils.cc
src/runtime/extra/contrib/dnnl/dnnl.cc
src/runtime/extra/contrib/cblas/dnnl_blas.cc)
add_library(tvm_dnnl_objs OBJECT ${DNNL_CONTRIB_SRC})
+ tvm_configure_target(tvm_dnnl_objs)
+ target_compile_definitions(tvm_dnnl_objs PRIVATE USE_JSON_RUNTIME=1)
target_link_libraries(tvm_dnnl_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_dnnl_objs
${EXTERN_LIBRARY_DNNL})
message(STATUS "Build with DNNL JSON runtime: " ${EXTERN_LIBRARY_DNNL})
-elseif(USE_DNNL STREQUAL "C_SRC")
+elseif(TVM_USE_DNNL STREQUAL "C_SRC")
find_library(EXTERN_LIBRARY_DNNL dnnl)
- tvm_file_glob(GLOB DNNL_CONTRIB_SRC src/runtime/extra/contrib/dnnl/dnnl.cc
+ file(GLOB DNNL_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/dnnl/dnnl.cc
src/runtime/extra/contrib/dnnl/dnnl_utils.cc
src/runtime/extra/contrib/cblas/dnnl_blas.cc)
add_library(tvm_dnnl_objs OBJECT ${DNNL_CONTRIB_SRC})
+ tvm_configure_target(tvm_dnnl_objs)
target_link_libraries(tvm_dnnl_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_dnnl_objs
${EXTERN_LIBRARY_DNNL})
message(STATUS "Build with DNNL C source module: " ${EXTERN_LIBRARY_DNNL})
-elseif(USE_DNNL STREQUAL "OFF")
+elseif(TVM_USE_DNNL STREQUAL "OFF")
# pass
else()
- message(FATAL_ERROR "Invalid option: USE_DNNL=" ${USE_DNNL})
+ message(FATAL_ERROR "Invalid option: TVM_USE_DNNL=" ${TVM_USE_DNNL})
endif()
diff --git a/cmake/modules/contrib/ExampleNPU.cmake
b/cmake/modules/contrib/ExampleNPU.cmake
index 6ae6257ce7..432779fcc5 100644
--- a/cmake/modules/contrib/ExampleNPU.cmake
+++ b/cmake/modules/contrib/ExampleNPU.cmake
@@ -16,28 +16,30 @@
# under the License.
# Example NPU Codegen
-if(USE_EXAMPLE_NPU_CODEGEN)
+if(TVM_USE_EXAMPLE_NPU_CODEGEN)
message(STATUS "Build with Example NPU codegen")
- tvm_file_glob(GLOB COMPILER_EXAMPLE_NPU_SRCS
src/relax/backend/contrib/example_npu/*.cc)
+ file(GLOB COMPILER_EXAMPLE_NPU_SRCS CONFIGURE_DEPENDS
src/relax/backend/contrib/example_npu/*.cc)
list(APPEND COMPILER_SRCS ${COMPILER_EXAMPLE_NPU_SRCS})
- tvm_file_glob(GLOB RUNTIME_EXAMPLE_NPU_SRCS
src/runtime/extra/contrib/example_npu/*.cc)
- if(NOT USE_EXAMPLE_NPU_RUNTIME)
+ file(GLOB RUNTIME_EXAMPLE_NPU_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/example_npu/*.cc)
+ if(NOT TVM_USE_EXAMPLE_NPU_RUNTIME)
add_library(tvm_example_npu_objs OBJECT ${RUNTIME_EXAMPLE_NPU_SRCS})
+ tvm_configure_target(tvm_example_npu_objs)
target_link_libraries(tvm_example_npu_objs PRIVATE
tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_example_npu_objs)
endif()
endif()
# Example NPU Runtime — goes into libtvm_runtime_extra.
-if(USE_EXAMPLE_NPU_RUNTIME)
+if(TVM_USE_EXAMPLE_NPU_RUNTIME)
message(STATUS "Build with Example NPU runtime")
- tvm_file_glob(GLOB RUNTIME_EXAMPLE_NPU_SRCS
src/runtime/extra/contrib/example_npu/*.cc)
+ file(GLOB RUNTIME_EXAMPLE_NPU_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/example_npu/*.cc)
add_library(tvm_example_npu_objs OBJECT ${RUNTIME_EXAMPLE_NPU_SRCS})
+ tvm_configure_target(tvm_example_npu_objs)
target_link_libraries(tvm_example_npu_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_example_npu_objs)
- add_definitions(-DTVM_GRAPH_EXECUTOR_EXAMPLE_NPU)
+ target_compile_definitions(tvm_example_npu_objs PRIVATE
TVM_GRAPH_EXECUTOR_EXAMPLE_NPU)
endif()
diff --git a/cmake/modules/contrib/NNAPI.cmake
b/cmake/modules/contrib/NNAPI.cmake
index 0b3f5e5db5..e7b6cd7bb3 100644
--- a/cmake/modules/contrib/NNAPI.cmake
+++ b/cmake/modules/contrib/NNAPI.cmake
@@ -16,27 +16,29 @@
# under the License.
# NNAPI Codegen
-if(USE_NNAPI_CODEGEN)
+if(TVM_USE_NNAPI_CODEGEN)
message(STATUS "Build with NNAPI codegen")
- tvm_file_glob(GLOB COMPILER_NNAPI_SRCS
src/relax/backend/contrib/nnapi/*.cc)
- tvm_file_glob(GLOB RUNTIME_NNAPI_SRCS src/runtime/extra/contrib/nnapi/*.cc)
+ file(GLOB COMPILER_NNAPI_SRCS CONFIGURE_DEPENDS
src/relax/backend/contrib/nnapi/*.cc)
+ file(GLOB RUNTIME_NNAPI_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/nnapi/*.cc)
list(APPEND COMPILER_SRCS ${COMPILER_NNAPI_SRCS})
- if(NOT USE_NNAPI_RUNTIME)
+ if(NOT TVM_USE_NNAPI_RUNTIME)
add_library(tvm_nnapi_objs OBJECT ${RUNTIME_NNAPI_SRCS})
+ tvm_configure_target(tvm_nnapi_objs)
target_link_libraries(tvm_nnapi_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_nnapi_objs)
endif()
endif()
# NNAPI Runtime — goes into libtvm_runtime_extra.
-if(USE_NNAPI_RUNTIME)
+if(TVM_USE_NNAPI_RUNTIME)
message(STATUS "Build with NNAPI runtime")
- tvm_file_glob(GLOB RUNTIME_NNAPI_SRCS src/runtime/extra/contrib/nnapi/*.cc)
+ file(GLOB RUNTIME_NNAPI_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/nnapi/*.cc)
add_library(tvm_nnapi_objs OBJECT ${RUNTIME_NNAPI_SRCS})
+ tvm_configure_target(tvm_nnapi_objs)
target_link_libraries(tvm_nnapi_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_nnapi_objs
neuralnetworks log)
- add_definitions(-DTVM_GRAPH_EXECUTOR_NNAPI)
+ target_compile_definitions(tvm_nnapi_objs PRIVATE TVM_GRAPH_EXECUTOR_NNAPI)
endif()
diff --git a/cmake/modules/contrib/ROCM.cmake b/cmake/modules/contrib/ROCM.cmake
index 24c1b4e698..778c1e276b 100644
--- a/cmake/modules/contrib/ROCM.cmake
+++ b/cmake/modules/contrib/ROCM.cmake
@@ -16,20 +16,21 @@
# under the License.
# HIPBLAS contrib goes into libtvm_runtime_extra.
-if(TVM_TIRX_USE_ROCM AND USE_HIPBLAS)
+if(TVM_TIRX_USE_ROCM AND TVM_USE_HIPBLAS)
message(STATUS "Build with HIPBLAS support")
- tvm_file_glob(GLOB HIPBLAS_CONTRIB_SRC
src/relax/backend/contrib/hipblas/*.cc)
+ file(GLOB HIPBLAS_CONTRIB_SRC CONFIGURE_DEPENDS
src/relax/backend/contrib/hipblas/*.cc)
list(APPEND COMPILER_SRCS ${HIPBLAS_CONTRIB_SRC})
- tvm_file_glob(GLOB HIPBLAS_CONTRIB_SRCS
src/runtime/extra/contrib/hipblas/*.cc)
+ file(GLOB HIPBLAS_CONTRIB_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/hipblas/*.cc)
add_library(tvm_hipblas_objs OBJECT ${HIPBLAS_CONTRIB_SRCS})
+ tvm_configure_target(tvm_hipblas_objs)
target_link_libraries(tvm_hipblas_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_hipblas_objs
${ROCM_HIPBLAS_LIBRARY})
if(NOT ROCM_HIPBLASLT_LIBRARY STREQUAL "ROCM_HIPBLASLT_LIBRARY-NOTFOUND")
target_link_libraries(tvm_runtime_extra PRIVATE ${ROCM_HIPBLASLT_LIBRARY})
endif()
-endif(TVM_TIRX_USE_ROCM AND USE_HIPBLAS)
+endif(TVM_TIRX_USE_ROCM AND TVM_USE_HIPBLAS)
-if(TVM_TIRX_USE_ROCM AND USE_THRUST)
+if(TVM_TIRX_USE_ROCM AND TVM_USE_THRUST)
message(STATUS "Build with rocThrust support")
# We need to override CXX to hipcc. This is required by rocthrust
if(${CMAKE_CXX_COMPILER} MATCHES "hipcc$")
@@ -42,6 +43,7 @@ if(TVM_TIRX_USE_ROCM AND USE_THRUST)
find_package(rocthrust REQUIRED)
set_source_files_properties(src/runtime/extra/contrib/thrust/thrust.cu
PROPERTIES LANGUAGE CXX)
add_library(tvm_rocthrust_objs OBJECT
src/runtime/extra/contrib/thrust/thrust.cu)
- target_link_libraries(tvm_rocthrust_objs PRIVATE tvm_runtime_extra_defs)
+ tvm_configure_target(tvm_rocthrust_objs)
+ target_link_libraries(tvm_rocthrust_objs PRIVATE tvm_runtime_extra_defs
roc::rocthrust)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_rocthrust_objs
roc::rocthrust)
-endif(TVM_TIRX_USE_ROCM AND USE_THRUST)
+endif(TVM_TIRX_USE_ROCM AND TVM_USE_THRUST)
diff --git a/cmake/modules/contrib/Random.cmake
b/cmake/modules/contrib/Random.cmake
index 215b73e0fb..1f8512ceed 100644
--- a/cmake/modules/contrib/Random.cmake
+++ b/cmake/modules/contrib/Random.cmake
@@ -15,10 +15,11 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_RANDOM)
+if(TVM_USE_RANDOM)
message(STATUS "Build with contrib.random")
- tvm_file_glob(GLOB RANDOM_CONTRIB_SRC
src/runtime/extra/contrib/random/random.cc)
+ file(GLOB RANDOM_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/random/random.cc)
add_library(tvm_random_objs OBJECT ${RANDOM_CONTRIB_SRC})
+ tvm_configure_target(tvm_random_objs)
target_link_libraries(tvm_random_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_random_objs)
-endif(USE_RANDOM)
+endif(TVM_USE_RANDOM)
diff --git a/cmake/modules/contrib/Sort.cmake b/cmake/modules/contrib/Sort.cmake
index 0c02fe861e..c796c0653b 100644
--- a/cmake/modules/contrib/Sort.cmake
+++ b/cmake/modules/contrib/Sort.cmake
@@ -15,10 +15,11 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_SORT)
+if(TVM_USE_SORT)
message(STATUS "Build with contrib.sort")
- tvm_file_glob(GLOB SORT_CONTRIB_SRC src/runtime/extra/contrib/sort/*.cc)
+ file(GLOB SORT_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/sort/*.cc)
add_library(tvm_sort_objs OBJECT ${SORT_CONTRIB_SRC})
+ tvm_configure_target(tvm_sort_objs)
target_link_libraries(tvm_sort_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_sort_objs)
-endif(USE_SORT)
+endif(TVM_USE_SORT)
diff --git a/cmake/modules/contrib/TensorRT.cmake
b/cmake/modules/contrib/TensorRT.cmake
index 299140b92b..b0f7d7ef79 100644
--- a/cmake/modules/contrib/TensorRT.cmake
+++ b/cmake/modules/contrib/TensorRT.cmake
@@ -15,30 +15,31 @@
# specific language governing permissions and limitations
# under the License.
-# TensorRT Codegen only. This can be enabled independently of
USE_TENSORRT_RUNTIME to enable
+# TensorRT Codegen only. This can be enabled independently of
TVM_USE_TENSORRT_RUNTIME to enable
# compilation of TensorRT modules without requiring TensorRT to be installed.
The compiled modules
-# will only be able to be executed using a TVM built with
USE_TENSORRT_RUNTIME=ON.
+# will only be able to be executed using a TVM built with
TVM_USE_TENSORRT_RUNTIME=ON.
include(FindPackageHandleStandardArgs)
-if(USE_TENSORRT_CODEGEN)
+if(TVM_USE_TENSORRT_CODEGEN)
message(STATUS "Build with TensorRT codegen")
- tvm_file_glob(GLOB COMPILER_TENSORRT_SRCS
src/relax/backend/contrib/tensorrt/*.cc)
+ file(GLOB COMPILER_TENSORRT_SRCS CONFIGURE_DEPENDS
src/relax/backend/contrib/tensorrt/*.cc)
set_source_files_properties(${COMPILER_TENSORRT_SRCS} PROPERTIES
COMPILE_FLAGS "-Wno-deprecated-declarations")
- tvm_file_glob(GLOB RUNTIME_TENSORRT_SRCS
src/runtime/extra/contrib/tensorrt/tensorrt_runtime.cc)
+ file(GLOB RUNTIME_TENSORRT_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/tensorrt/tensorrt_runtime.cc)
set_source_files_properties(${RUNTIME_TENSORRT_SRCS} PROPERTIES
COMPILE_FLAGS "-Wno-deprecated-declarations")
list(APPEND COMPILER_SRCS ${COMPILER_TENSORRT_SRCS})
- if(NOT USE_TENSORRT_RUNTIME)
+ if(NOT TVM_USE_TENSORRT_RUNTIME)
add_library(tvm_tensorrt_objs OBJECT ${RUNTIME_TENSORRT_SRCS})
+ tvm_configure_target(tvm_tensorrt_objs)
target_link_libraries(tvm_tensorrt_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_tensorrt_objs)
endif()
endif()
# TensorRT Runtime — goes into libtvm_runtime_extra.
-if(USE_TENSORRT_RUNTIME)
- if(IS_DIRECTORY ${USE_TENSORRT_RUNTIME})
- set(TENSORRT_ROOT_DIR ${USE_TENSORRT_RUNTIME})
+if(TVM_USE_TENSORRT_RUNTIME)
+ if(IS_DIRECTORY ${TVM_USE_TENSORRT_RUNTIME})
+ set(TENSORRT_ROOT_DIR ${TVM_USE_TENSORRT_RUNTIME})
message(STATUS "Custom TensorRT path: " ${TENSORRT_ROOT_DIR})
endif()
find_path(TENSORRT_INCLUDE_DIR NvInfer.h HINTS ${TENSORRT_ROOT_DIR}
PATH_SUFFIXES include)
@@ -48,14 +49,16 @@ if(USE_TENSORRT_RUNTIME)
message(ERROR "Could not find TensorRT.")
endif()
message(STATUS "TENSORRT_LIB_DIR: " ${TENSORRT_LIB_DIR})
- include_directories(${TENSORRT_INCLUDE_DIR})
# TRT runtime sources
- tvm_file_glob(GLOB RUNTIME_TENSORRT_SRCS
src/runtime/extra/contrib/tensorrt/*.cc)
+ file(GLOB RUNTIME_TENSORRT_SRCS CONFIGURE_DEPENDS
src/runtime/extra/contrib/tensorrt/*.cc)
set_source_files_properties(${RUNTIME_TENSORRT_SRCS} PROPERTIES
COMPILE_FLAGS "-Wno-deprecated-declarations")
add_library(tvm_tensorrt_objs OBJECT ${RUNTIME_TENSORRT_SRCS})
+ tvm_configure_target(tvm_tensorrt_objs)
target_link_libraries(tvm_tensorrt_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_tensorrt_objs
${TENSORRT_LIB_DIR})
- # Set defines
- add_definitions(-DTVM_GRAPH_EXECUTOR_TENSORRT)
+ target_include_directories(tvm_tensorrt_objs PRIVATE
${TENSORRT_INCLUDE_DIR})
+ target_include_directories(tvm_compiler PRIVATE ${TENSORRT_INCLUDE_DIR})
+ target_compile_definitions(tvm_tensorrt_objs PRIVATE
TVM_GRAPH_EXECUTOR_TENSORRT)
+ target_compile_definitions(tvm_compiler PRIVATE
TVM_GRAPH_EXECUTOR_TENSORRT)
endif()
diff --git a/cmake/modules/contrib/vllm.cmake b/cmake/modules/contrib/vllm.cmake
index 56b452fe7d..006ed2eca1 100644
--- a/cmake/modules/contrib/vllm.cmake
+++ b/cmake/modules/contrib/vllm.cmake
@@ -15,13 +15,14 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_VLLM)
+if(TVM_USE_VLLM)
message(STATUS "Build with vllm paged attention kernel.")
- include_directories(src/runtime/extra/contrib/vllm)
enable_language(CUDA)
- tvm_file_glob(GLOB VLLM_CONTRIB_SRC src/runtime/extra/contrib/vllm/*.cu
src/runtime/extra/contrib/vllm/*.cc)
+ file(GLOB VLLM_CONTRIB_SRC CONFIGURE_DEPENDS
src/runtime/extra/contrib/vllm/*.cu src/runtime/extra/contrib/vllm/*.cc)
add_library(tvm_vllm_objs OBJECT ${VLLM_CONTRIB_SRC})
+ tvm_configure_target(tvm_vllm_objs)
+ target_include_directories(tvm_vllm_objs PRIVATE
src/runtime/extra/contrib/vllm)
target_link_libraries(tvm_vllm_objs PRIVATE tvm_runtime_extra_defs)
target_link_libraries(tvm_runtime_extra PRIVATE tvm_vllm_objs)
-endif(USE_VLLM)
+endif(TVM_USE_VLLM)
diff --git a/cmake/utils/CCache.cmake b/cmake/utils/CCache.cmake
index 55fa069af4..c80e8aa16c 100644
--- a/cmake/utils/CCache.cmake
+++ b/cmake/utils/CCache.cmake
@@ -15,31 +15,31 @@
# specific language governing permissions and limitations
# under the License.
-if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
+if(TVM_USE_CCACHE) # True for AUTO, ON, /path/to/ccache
if(DEFINED CMAKE_C_COMPILER_LAUNCHER)
- if("${USE_CCACHE}" STREQUAL "AUTO")
+ if("${TVM_USE_CCACHE}" STREQUAL "AUTO")
message(STATUS "CMAKE_C_COMPILER_LAUNCHER already defined. Not using
ccache.")
- elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
+ elseif("${TVM_USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
message(FATAL_ERROR "CMAKE_C_COMPILER_LAUNCHER already defined.
Refusing to override with ccache. Either unset or disable ccache.")
endif()
elseif(DEFINED CMAKE_CXX_COMPILER_LAUNCHER)
- if("${USE_CCACHE}" STREQUAL "AUTO")
+ if("${TVM_USE_CCACHE}" STREQUAL "AUTO")
message(STATUS "CMAKE_CXX_COMPILER_LAUNCHER already defined. Not using
ccache.")
- elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
+ elseif("${TVM_USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
message(FATAL_ERROR "CMAKE_CXX_COMPILER_LAUNCHER already defined.
Refusing to override with ccache. Either unset or disable ccache.")
endif()
elseif(DEFINED CMAKE_CUDA_COMPILER_LAUNCHER)
- if("${USE_CCACHE}" STREQUAL "AUTO")
+ if("${TVM_USE_CCACHE}" STREQUAL "AUTO")
message(STATUS "CMAKE_CUDA_COMPILER_LAUNCHER already defined. Not using
ccache.")
- elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
+ elseif("${TVM_USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
message(FATAL_ERROR "CMAKE_CUDA_COMPILER_LAUNCHER already defined.
Refusing to override with ccache. Either unset or disable ccache.")
endif()
else()
- if("${USE_CCACHE}" STREQUAL "AUTO") # Auto mode
+ if("${TVM_USE_CCACHE}" STREQUAL "AUTO") # Auto mode
find_program(CCACHE_FOUND "ccache")
if(CCACHE_FOUND)
message(STATUS "Found the path to ccache, enabling ccache")
@@ -47,16 +47,16 @@ if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
else()
message(STATUS "Didn't find the path to CCACHE, disabling ccache")
endif(CCACHE_FOUND)
- elseif("${USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
+ elseif("${TVM_USE_CCACHE}" MATCHES ${IS_TRUE_PATTERN})
find_program(CCACHE_FOUND "ccache")
if(CCACHE_FOUND)
message(STATUS "Found the path to ccache, enabling ccache")
set(PATH_TO_CCACHE "ccache")
else()
- message(FATAL_ERROR "Cannot find ccache. Set USE_CCACHE mode to AUTO
or OFF to build without ccache. USE_CCACHE=" "${USE_CCACHE}")
+ message(FATAL_ERROR "Cannot find ccache. Set TVM_USE_CCACHE mode to
AUTO or OFF to build without ccache. TVM_USE_CCACHE=" "${TVM_USE_CCACHE}")
endif(CCACHE_FOUND)
else() # /path/to/ccache
- set(PATH_TO_CCACHE "${USE_CCACHE}")
+ set(PATH_TO_CCACHE "${TVM_USE_CCACHE}")
message(STATUS "Setting ccache path to " "${PATH_TO_CCACHE}")
endif()
# Set the flag for ccache
@@ -66,4 +66,4 @@ if(USE_CCACHE) # True for AUTO, ON, /path/to/ccache
set(CMAKE_CUDA_COMPILER_LAUNCHER "${PATH_TO_CCACHE}")
endif()
endif()
-endif(USE_CCACHE)
+endif(TVM_USE_CCACHE)
diff --git a/cmake/utils/FindNVSHMEM.cmake b/cmake/utils/FindNVSHMEM.cmake
index 1a833332a2..366fbed937 100644
--- a/cmake/utils/FindNVSHMEM.cmake
+++ b/cmake/utils/FindNVSHMEM.cmake
@@ -19,10 +19,10 @@
# Enhanced version of find NVSHMEM.
#
# Usage:
-# find_nvshmem(${USE_NVSHMEM})
+# find_nvshmem(${TVM_USE_NVSHMEM})
#
-# - When USE_NVSHMEM=ON, use auto search
-# - When USE_NVSHMEM=/path/to/installed/nvshmem, use the installed nvshmem
path.
+# - When TVM_USE_NVSHMEM=ON, use auto search
+# - When TVM_USE_NVSHMEM=/path/to/installed/nvshmem, use the installed nvshmem
path.
# Can be useful when nvshmem is installed at specified location.
#
# Provide variables:
diff --git a/cmake/utils/Library.cmake b/cmake/utils/Library.cmake
index f1ec6be620..b3417e655a 100644
--- a/cmake/utils/Library.cmake
+++ b/cmake/utils/Library.cmake
@@ -15,72 +15,48 @@
# specific language governing permissions and limitations
# under the License.
-# Helpers for configuring library targets.
-
-# Hide symbols from static archives linked into a shared library. This prevents
-# downstream libraries from accidentally binding to private archive symbols
such
-# as those from libstdc++_nonshared.a.
-function(tvm_hide_static_linked_lib_symbols target_name)
- if(HIDE_PRIVATE_SYMBOLS
- AND CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD|OpenBSD"
- AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang"
- )
- target_link_options(${target_name} PRIVATE "-Wl,--exclude-libs,ALL")
+# Apply parent compilation policy to the targets that compile, including
objects.
+# KEEP_SYMBOLS preserves the unannotated public APIs of bundled third-party
DSOs.
+function(tvm_configure_target target)
+ set_target_properties(${target} PROPERTIES
+ POSITION_INDEPENDENT_CODE ON
+ CXX_STANDARD 20
+ CXX_STANDARD_REQUIRED ON
+ CXX_EXTENSIONS OFF
+ CUDA_STANDARD 20
+ CUDA_STANDARD_REQUIRED ON)
+ target_include_directories(${target} PRIVATE "${PROJECT_SOURCE_DIR}/include")
+ target_compile_definitions(${target} PRIVATE TVM_VERSION="${TVM_VERSION}")
+ if(TVM_LOG_BEFORE_THROW)
+ target_compile_definitions(${target} PRIVATE TVM_LOG_BEFORE_THROW=1)
endif()
-endfunction()
-
-#######################################################
-# tvm_configure_target_library(target_name [RUNTIME_MODULE])
-#
-# Configure a TVM library target. The target always gets a relative rpath
-# ($ORIGIN / @loader_path) so that sibling shared libraries in the same
-# directory resolve each other regardless of the install location (e.g. inside
a
-# Python wheel).
-#
-# For shared libraries and runtime modules, hide symbols that come from linked
-# static archives so downstream libraries cannot accidentally bind to private
-# archive symbols such as those from libstdc++_nonshared.a.
-#
-# With the RUNTIME_MODULE option -- used for the optional runtime backend
-# libraries (tvm_runtime_cuda, tvm_runtime_vulkan, ...) -- the target is also
-# emitted into the build "lib" directory and installed; when building the
Python
-# module it is additionally installed into the package "lib" directory. Targets
-# that manage their own output directory / install rules (tvm_compiler,
-# tvm_runtime, ...) omit the option and take only the rpath.
-#
-# No-op if the target does not exist.
-function(tvm_configure_target_library target_name)
- if(NOT TARGET ${target_name})
- return()
+ if(MSVC)
+ target_compile_definitions(${target} PRIVATE WIN32_LEAN_AND_MEAN
_CRT_SECURE_NO_WARNINGS
+ _SCL_SECURE_NO_WARNINGS _ENABLE_EXTENDED_ALIGNED_STORAGE NOMINMAX)
+ target_compile_options(${target} PRIVATE
$<$<COMPILE_LANGUAGE:CXX>:/bigobj;/permissive-;/EHsc>)
+ if(TVM_USE_MSVC_MT)
+ set_property(TARGET ${target} PROPERTY MSVC_RUNTIME_LIBRARY
"MultiThreaded$<$<CONFIG:Debug>:Debug>")
+ endif()
+ else()
+ target_compile_options(${target} PRIVATE
$<$<COMPILE_LANGUAGE:C,CXX>:-Wall>)
+ if(TVM_HIDE_PRIVATE_SYMBOLS AND NOT ARGV1 STREQUAL "KEEP_SYMBOLS")
+ set_target_properties(${target} PROPERTIES CXX_VISIBILITY_PRESET hidden
C_VISIBILITY_PRESET hidden)
+ target_compile_options(${target} PRIVATE
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=-fvisibility=hidden>)
+ endif()
endif()
- cmake_parse_arguments(ARG "RUNTIME_MODULE" "" "" ${ARGN})
+ target_link_options(${target} PRIVATE ${TVM_LINKER_FLAGS})
+endfunction()
+# Keep parent shared libraries relocatable and hide linked archive internals.
+function(tvm_configure_target_library target)
if(APPLE)
- set_target_properties(${target_name} PROPERTIES
- BUILD_RPATH "@loader_path"
- INSTALL_RPATH "@loader_path"
- )
+ set_target_properties(${target} PROPERTIES BUILD_RPATH "@loader_path"
INSTALL_RPATH "@loader_path")
elseif(UNIX)
- set_target_properties(${target_name} PROPERTIES
- BUILD_RPATH "\$ORIGIN"
- INSTALL_RPATH "\$ORIGIN"
- )
- endif()
-
- get_target_property(TVM_TARGET_TYPE ${target_name} TYPE)
- if(TVM_TARGET_TYPE STREQUAL "SHARED_LIBRARY" OR TVM_TARGET_TYPE STREQUAL
"MODULE_LIBRARY")
- tvm_hide_static_linked_lib_symbols(${target_name})
+ set_target_properties(${target} PROPERTIES BUILD_RPATH "$ORIGIN"
INSTALL_RPATH "$ORIGIN")
endif()
-
- if(ARG_RUNTIME_MODULE)
- set_target_properties(${target_name} PROPERTIES
- LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
- ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib"
- )
- install(TARGETS ${target_name} DESTINATION lib${LIB_SUFFIX} COMPONENT tvm)
- if(TVM_BUILD_PYTHON_MODULE)
- install(TARGETS ${target_name} DESTINATION "lib" COMPONENT tvm)
- endif()
+ if(TVM_HIDE_PRIVATE_SYMBOLS
+ AND CMAKE_SYSTEM_NAME MATCHES "Linux|Android|FreeBSD|NetBSD|OpenBSD"
+ AND CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
+ target_link_options(${target} PRIVATE "LINKER:--exclude-libs,ALL")
endif()
endfunction()
diff --git a/cmake/utils/Linker.cmake b/cmake/utils/Linker.cmake
index dfc1891fd0..1b26aae279 100644
--- a/cmake/utils/Linker.cmake
+++ b/cmake/utils/Linker.cmake
@@ -18,7 +18,7 @@
#######################################################
function(find_and_set_linker use_alternative_linker)
- if(${use_alternative_linker} MATCHES ${IS_FALSE_PATTERN})
+ if("${use_alternative_linker}" MATCHES ${IS_FALSE_PATTERN})
return()
endif()
@@ -28,11 +28,9 @@ function(find_and_set_linker use_alternative_linker)
endif()
macro(add_to_linker_flags flag)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}"
PARENT_SCOPE)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}"
PARENT_SCOPE)
- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${flag}"
PARENT_SCOPE)
- message(STATUS "Added \"${flag}\" to linker flags "
${CMAKE_SHARED_LINKER_FLAGS})
- endmacro(add_to_linker_flags)
+ set(TVM_LINKER_FLAGS "${flag}" PARENT_SCOPE)
+ message(STATUS "Parent linker option: ${flag}")
+ endmacro()
find_program(MOLD_BIN "mold")
find_program(LLD_BIN "lld")
@@ -49,7 +47,7 @@ function(find_and_set_linker use_alternative_linker)
NO_CACHE
)
if(MOLD_LIBEXEC_DIR)
- add_to_linker_flags(" -B \"${MOLD_LIBEXEC_DIR}\"")
+ add_to_linker_flags("-B${MOLD_LIBEXEC_DIR}")
return()
endif()
else()
@@ -58,8 +56,8 @@ function(find_and_set_linker use_alternative_linker)
endif()
elseif(LLD_BIN)
add_to_linker_flags("-fuse-ld=lld")
- elseif(${use_alternative_linker} MATCHES ${IS_TRUE_PATTERN})
- message(FATAL_ERROR "Could not find 'mold' or 'lld' executable but
USE_ALTERNATIVE_LINKER was set to ON")
+ elseif("${use_alternative_linker}" MATCHES ${IS_TRUE_PATTERN})
+ message(FATAL_ERROR "Could not find 'mold' or 'lld' executable but
TVM_USE_ALTERNATIVE_LINKER was set to ON")
endif()
endfunction(find_and_set_linker)
diff --git a/cmake/utils/Summary.cmake b/cmake/utils/Summary.cmake
deleted file mode 100644
index acb5703f60..0000000000
--- a/cmake/utils/Summary.cmake
+++ /dev/null
@@ -1,77 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-function(pad_string output str padchar length)
- string(LENGTH "${str}" _strlen)
- math(EXPR _strlen "${length} - ${_strlen}")
-
- if(_strlen GREATER 0)
- unset(_pad)
- foreach(_i RANGE 1 ${_strlen}) # inclusive
- string(APPEND _pad ${padchar})
- endforeach()
- string(APPEND str ${_pad})
- endif()
-
- set(${output} "${str}" PARENT_SCOPE)
-endfunction()
-
-macro(print_summary)
- message(STATUS " ---------------- Summary ----------------")
-
- # Show some basic system information
- message(STATUS " CMake version : ${CMAKE_VERSION}")
- message(STATUS " CMake executable : ${CMAKE_COMMAND}")
- message(STATUS " Generator : ${CMAKE_GENERATOR}")
- message(STATUS " System : ${CMAKE_SYSTEM_NAME}")
- message(STATUS " C++ compiler : ${CMAKE_CXX_COMPILER}")
- message(STATUS " C++ compiler ID : ${CMAKE_CXX_COMPILER_ID}")
- message(STATUS " C++ compiler version : ${CMAKE_CXX_COMPILER_VERSION}")
- message(STATUS " CXX flags : ${CMAKE_CXX_FLAGS}")
- message(STATUS " CXX launcher : ${CMAKE_CXX_COMPILER_LAUNCHER}")
- message(STATUS " Linker flags : ${CMAKE_SHARED_LINKER_FLAGS}")
- message(STATUS " Build type : ${CMAKE_BUILD_TYPE}")
- get_directory_property(READABLE_COMPILE_DEFS DIRECTORY
${PROJECT_SOURCE_DIR} COMPILE_DEFINITIONS)
- message(STATUS " Compile definitions : ${READABLE_COMPILE_DEFS}")
-
- list(SORT TVM_ALL_OPTIONS)
- message(STATUS " Options:")
-
- # Compute padding necessary for options
- set(MAX_LENGTH 0)
- foreach(OPTION ${TVM_ALL_OPTIONS})
- string(LENGTH ${OPTION} OPTIONLENGTH)
- if(${OPTIONLENGTH} GREATER ${MAX_LENGTH})
- set(MAX_LENGTH ${OPTIONLENGTH})
- endif()
- endforeach()
- math(EXPR PADDING_LENGTH "${MAX_LENGTH} + 3")
-
- # Print each of the options (padded out so they're all aligned)
- foreach(OPTION ${TVM_ALL_OPTIONS})
- set(OPTION_VALUE "${${OPTION}}")
- pad_string(OUT " ${OPTION}" " " ${PADDING_LENGTH})
- message(STATUS ${OUT} " : " ${OPTION_VALUE})
- endforeach()
-endmacro()
-
-function(dump_options_to_file tvm_options)
- file(REMOVE ${CMAKE_BINARY_DIR}/TVMBuildOptions.txt)
- foreach(option ${tvm_options})
- file(APPEND ${CMAKE_BINARY_DIR}/TVMBuildOptions.txt "${option}
${${option}} \n")
- endforeach()
-endfunction()
diff --git a/cmake/utils/Utils.cmake b/cmake/utils/Utils.cmake
index 1b5b1c2fd2..c55edc56b9 100644
--- a/cmake/utils/Utils.cmake
+++ b/cmake/utils/Utils.cmake
@@ -15,66 +15,6 @@
# specific language governing permissions and limitations
# under the License.
-macro(__tvm_option variable description value)
- if(NOT DEFINED ${variable})
- set(${variable} ${value} CACHE STRING ${description})
- endif()
-endmacro()
-
-set(TVM_ALL_OPTIONS)
-
-#######################################################
-# An option that the user can select. Can accept condition to control when
option is available for user.
-# Usage:
-# tvm_option(<option_variable> "doc string" <initial value or boolean
expression> [IF <condition>])
-macro(tvm_option variable description value)
- set(__value ${value})
- set(__condition "")
- set(__varname "__value")
- list(APPEND TVM_ALL_OPTIONS ${variable})
- foreach(arg ${ARGN})
- if(arg STREQUAL "IF" OR arg STREQUAL "if")
- set(__varname "__condition")
- else()
- list(APPEND ${__varname} ${arg})
- endif()
- endforeach()
- unset(__varname)
- if("${__condition}" STREQUAL "")
- set(__condition 2 GREATER 1)
- endif()
-
- if(${__condition})
- if("${__value}" MATCHES ";")
- # list values directly pass through
- __tvm_option(${variable} "${description}" "${__value}")
- elseif(DEFINED ${__value})
- if(${__value})
- __tvm_option(${variable} "${description}" ON)
- else()
- __tvm_option(${variable} "${description}" OFF)
- endif()
- else()
- __tvm_option(${variable} "${description}" "${__value}")
- endif()
- else()
- unset(${variable} CACHE)
- endif()
-endmacro()
-
-function(assign_source_group group)
- foreach(_source IN ITEMS ${ARGN})
- if (IS_ABSOLUTE "${_source}")
- file(RELATIVE_PATH _source_rel "${CMAKE_CURRENT_SOURCE_DIR}"
"${_source}")
- else()
- set(_source_rel "${_source}")
- endif()
- get_filename_component(_source_path "${_source_rel}" PATH)
- string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
- source_group("${group}\\${_source_path_msvc}" FILES "${_source}")
- endforeach()
-endfunction(assign_source_group)
-
# From CMake documentation:
# True if the constant is 1, ON, YES, TRUE, Y, or a non-zero number.
# False if the constant is 0, OFF, NO, FALSE, N, IGNORE, NOTFOUND, the empty
string, or ends in the suffix -NOTFOUND.
@@ -84,21 +24,3 @@ endfunction(assign_source_group)
# CMake's regex is weak
set(IS_FALSE_PATTERN
"^[Oo][Ff][Ff]$|^0$|^[Ff][Aa][Ll][Ss][Ee]$|^[Nn][Oo]$|^[Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd]$|.*-[Nn][Oo][Tt][Ff][Oo][Uu][Nn][Dd]$|^$")
set(IS_TRUE_PATTERN
"^[Oo][Nn]$|^[1-9][0-9]*$|^[Tt][Rr][Uu][Ee]$|^[Yy][Ee][Ss]$|^[Yy]$")
-
-# Custom file() macro that automatically uses CONFIGURE_DEPENDS if CMake
-# supports it. CONFIGURE_DEPENDS scans the globbed directories on each build to
-# check if any files have been added/removed. This has a small build overhead,
-# but ensures that you don't manually have to rerun cmake if files were added.
-# The macro should be used like so:
-# tvm_file_glob(GLOB VARIABLE_NAME dir/*.cc dir/*c)
-# or
-# tvm_file_glob(GLOB_RECURSE VARIABLE_NAME dir/*/*.cc)
-if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.12.0")
- macro(tvm_file_glob glob variable)
- file(${glob} ${variable} CONFIGURE_DEPENDS ${ARGN})
- endmacro()
-else()
- macro(tvm_file_glob)
- file(${glob} ${variable} ${ARGN})
- endmacro()
-endif()
diff --git a/docs/contribute/testing.rst b/docs/contribute/testing.rst
index 14ad21e875..9caf9a4350 100644
--- a/docs/contribute/testing.rst
+++ b/docs/contribute/testing.rst
@@ -49,7 +49,7 @@ In order for a test to be run, all of the following must be
true.
appear in the environment variable `TVM_TEST_TARGETS`.
- For parametrized tests using the `target` fixture, the build
- configuration in `config.cmake` must enable the corresponding
+ configuration passed to CMake must enable the corresponding
runtime.
Unit-Test File Contents
@@ -64,7 +64,7 @@ that cannot run on the current machine with
:py:func:`tvm.testing.device_enabled`, and obtain its device with
``tvm.device_from_target(target)``. The function is run once per target, the
success/failure of each is reported separately, and a target whose device
-is disabled in ``config.cmake`` or absent from the machine is reported as
+is disabled in the CMake configuration or absent from the machine is reported
as
skipped.
.. code-block:: python
@@ -132,7 +132,7 @@ marks are as follows.
available. The :py:mod:`tvm.testing.env` module exposes one memoized
probe per capability (e.g. ``has_cuda()``, ``has_rocm()``,
``has_vulkan()``, ``has_gpu()``, ``has_llvm()``), each of which
- returns ``False`` when the runtime is disabled in ``config.cmake`` or
+ returns ``False`` when the runtime is disabled in the CMake configuration or
no compatible device is present. Pair it with ``@pytest.mark.gpu``
for tests that use the GPU::
diff --git a/docs/errors.rst b/docs/errors.rst
index be3c6df83f..bb1a3fc023 100644
--- a/docs/errors.rst
+++ b/docs/errors.rst
@@ -36,7 +36,7 @@ What to Check First
- Make sure the TVM Python package and native libraries come from the
same build. A common symptom of a mismatched environment is importing
Python files from one checkout while loading ``libtvm`` from another.
-- Check that the required runtime is enabled in ``config.cmake``. For
+- Check that the required runtime is enabled in the CMake configuration. For
example, CUDA tests and CUDA compilation require a TVM build with
CUDA support enabled.
- Check that the target hardware is available to the process. GPU
@@ -58,7 +58,7 @@ filing an issue:
- The TVM version or git commit hash.
- The Python version, operating system, and hardware.
- The target and runtime being used, such as LLVM, CUDA, Vulkan, or RPC.
-- The relevant build configuration from ``config.cmake``.
+- The relevant build configuration from ``build/CMakeCache.txt``.
- A minimal script, model, input shape, or IR module that reproduces the
failure.
- The full error message, including both Python and C++ stack traces
diff --git a/docs/how_to/tutorials/bring_your_own_codegen.py
b/docs/how_to/tutorials/bring_your_own_codegen.py
index 50a57b5d5e..ba0a34fd06 100644
--- a/docs/how_to/tutorials/bring_your_own_codegen.py
+++ b/docs/how_to/tutorials/bring_your_own_codegen.py
@@ -41,8 +41,8 @@ visible with nothing hidden. TensorRT then runs the
identical flow for real, so
we cross-check its result against a reference.
**Prerequisites**: the example NPU sections need TVM built with
-``USE_EXAMPLE_NPU_CODEGEN=ON`` and ``USE_EXAMPLE_NPU_RUNTIME=ON``; the TensorRT
-sections need ``USE_TENSORRT_CODEGEN=ON``, ``USE_TENSORRT_RUNTIME=ON`` and
+``TVM_USE_EXAMPLE_NPU_CODEGEN=ON`` and ``TVM_USE_EXAMPLE_NPU_RUNTIME=ON``; the
TensorRT
+sections need ``TVM_USE_TENSORRT_CODEGEN=ON``, ``TVM_USE_TENSORRT_RUNTIME=ON``
and
``TVM_TIRX_USE_CUDA=ON`` plus a CUDA GPU and a matching TensorRT install (from
NVIDIA's
``pip install tensorrt`` packages or the TensorRT archive); the final
deployment
section also needs PyTorch. Each section degrades gracefully when its backend
is
diff --git a/docs/how_to/tutorials/cross_compilation_and_rpc.py
b/docs/how_to/tutorials/cross_compilation_and_rpc.py
index 04bc1d59f2..58caaf450d 100644
--- a/docs/how_to/tutorials/cross_compilation_and_rpc.py
+++ b/docs/how_to/tutorials/cross_compilation_and_rpc.py
@@ -53,8 +53,8 @@ and the Firefly-RK3399 for an OpenCL example.
# git clone --recursive https://github.com/apache/tvm tvm
# cd tvm
# mkdir build && cd build
-# cp ../cmake/config.cmake .
-# cmake .. && cmake --build . --parallel $(nproc)
+# cmake .. -DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF
+# cmake --build . --parallel $(nproc)
#
# After building the runtime successfully, we need to set environment variables
# in :code:`~/.bashrc` file. We can edit :code:`~/.bashrc`
@@ -278,7 +278,7 @@ print(f"{cost:g} secs/op")
# set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
#
# Build the runtime from the TVM repository root. Enable target-specific
-# options such as ``TVM_TIRX_USE_OPENCL`` or vendor runtime support in
``config.cmake``.
+# CMake options such as ``-DTVM_TIRX_USE_OPENCL=ON`` or vendor runtime support.
# Build any target-specific runtime libraries that your deployment needs, such
# as ``tvm_runtime_opencl`` for OpenCL.
#
@@ -286,12 +286,9 @@ print(f"{cost:g} secs/op")
#
# mkdir cross_build
# cd cross_build
-# cp ../cmake/config.cmake ./
-#
# # Enable other options as needed, e.g. TVM_TIRX_USE_OPENCL or vendor
runtimes.
-# sed -i "s|TVM_TIRX_USE_LLVM.*)|TVM_TIRX_USE_LLVM OFF)|" config.cmake
-#
-# cmake -DCMAKE_TOOLCHAIN_FILE=/YYY/aarch64-linux-gnu.cmake
-DCMAKE_BUILD_TYPE=Release ..
+# cmake .. -DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF \
+# -DCMAKE_TOOLCHAIN_FILE=/YYY/aarch64-linux-gnu.cmake
-DCMAKE_BUILD_TYPE=Release
# cmake --build . --target runtime -j
# # Optional example when TVM_TIRX_USE_OPENCL is enabled:
# # cmake --build . --target tvm_runtime_opencl -j
@@ -405,9 +402,8 @@ print(f"{cost:g} secs/op")
# .. code-block:: bash
#
# mkdir -p build && cd build
-# cp ../cmake/config.cmake .
-# sed -i "s/TVM_TIRX_USE_OPENCL OFF/TVM_TIRX_USE_OPENCL ON/" config.cmake
-# cmake .. && cmake --build . --parallel $(nproc)
+# cmake .. -DTVM_TIRX_USE_OPENCL=ON -DTVM_TIRX_USE_LLVM=OFF
-DTVM_TIRX_USE_CUDA=OFF
+# cmake --build . --parallel $(nproc)
#
# The following function shows how we run an OpenCL kernel remotely
diff --git a/docs/install/from_source.rst b/docs/install/from_source.rst
index 6d63f9a06d..a168155ac1 100644
--- a/docs/install/from_source.rst
+++ b/docs/install/from_source.rst
@@ -99,40 +99,32 @@ You can also choose to clone the source repo from GitHub.
Step 3. Configure and Build
---------------------------
-Create a build directory and run CMake to configure the build. The following
example shows how to build
+Configure the build from the repository root with explicit CMake options.
Enable
+GPU SDKs and vendor libraries as needed:
.. code:: bash
cd tvm
- rm -rf build && mkdir build && cd build
- # Specify the build configuration via CMake options
- cp ../cmake/config.cmake .
-
-We want to specifically tweak the following flags by appending them to the end
of the configuration file:
-
-.. code:: bash
-
- # controls default compilation flags (Candidates: Release, Debug,
RelWithDebInfo)
- echo "set(CMAKE_BUILD_TYPE RelWithDebInfo)" >> config.cmake
-
- # LLVM is a must dependency for compiler end
- echo "set(TVM_TIRX_USE_LLVM \"llvm-config --ignore-libllvm
--link-static\")" >> config.cmake
- echo "set(HIDE_PRIVATE_SYMBOLS ON)" >> config.cmake
-
- # GPU SDKs, turn on if needed
- echo "set(TVM_TIRX_USE_CUDA OFF)" >> config.cmake
- echo "set(TVM_TIRX_USE_METAL OFF)" >> config.cmake
- echo "set(TVM_TIRX_USE_VULKAN OFF)" >> config.cmake
- echo "set(TVM_TIRX_USE_OPENCL OFF)" >> config.cmake
-
- # cuBLAS, cuDNN, cutlass support, turn on if needed
- echo "set(USE_CUBLAS OFF)" >> config.cmake
- echo "set(USE_CUDNN OFF)" >> config.cmake
- echo "set(USE_CUTLASS OFF)" >> config.cmake
+ cmake -S . -B build \
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo \
+ -DTVM_TIRX_USE_LLVM="llvm-config --ignore-libllvm --link-static" \
+ -DTVM_HIDE_PRIVATE_SYMBOLS=ON \
+ -DTVM_TIRX_USE_CUDA=OFF \
+ -DTVM_TIRX_USE_METAL=OFF \
+ -DTVM_TIRX_USE_VULKAN=OFF \
+ -DTVM_TIRX_USE_OPENCL=OFF \
+ -DTVM_USE_CUBLAS=OFF \
+ -DTVM_USE_CUDNN=OFF \
+ -DTVM_USE_CUTLASS=OFF
+
+CMake stores these values in ``build/CMakeCache.txt``. To change an option,
+rerun the configure command with its new ``-D`` value. Parent TVM features use
+``TVM_USE_*``; core features retain ``TVM_TIRX_USE_*`` and FFI options retain
+``TVM_FFI_*``. CMake also supports local ``CMakeUserPresets.json`` presets.
.. note::
- ``HIDE_PRIVATE_SYMBOLS`` is a configuration option that enables the
``-fvisibility=hidden`` flag.
+ ``TVM_HIDE_PRIVATE_SYMBOLS`` is a configuration option that enables the
``-fvisibility=hidden`` flag.
This flag helps prevent potential symbol conflicts between TVM and
PyTorch. These conflicts arise due to
the frameworks shipping LLVMs of different versions.
@@ -142,16 +134,16 @@ We want to specifically tweak the following flags by
appending them to the end o
- ``RelWithDebInfo`` sets ``-O2 -g -DNDEBUG`` (recommended)
- ``Release`` sets ``-O3 -DNDEBUG``
-Once ``config.cmake`` is edited accordingly, kick off build with the commands
below:
+After configuration succeeds, build with:
.. code-block:: bash
- cmake .. && cmake --build . --parallel $(nproc)
+ cmake --build build --parallel $(nproc)
.. note::
``nproc`` may not be available on all systems, please replace it with the
number of cores on your system
-A success build should produce ``libtvm`` and ``libtvm_runtime`` under
``build/`` directory.
+A successful build produces the compiler and runtime libraries under
``build/lib/``.
Apache TVM relies on the tvm-ffi package to support its python bindings.
Therefore, after we finish the build, we need to install the tvm-ffi package.
@@ -200,22 +192,16 @@ Therefore, it is highly recommended to validate Apache
TVM installation before u
>>> python -c "import tvm; print(tvm.base._LOADED_LIBS['tvm_runtime'])"
<CDLL '/some-path/lib/python3.11/site-packages/tvm/libtvm_runtime.dylib',
handle 95ada510 at 0x1030e4e50>
-**Step 3. Reflect TVM build option.** Sometimes when downstream application
fails, it could likely be some mistakes with a wrong TVM commit, or wrong build
flags. To find it out, the following commands will be helpful:
+**Step 3. Inspect the build configuration.** For a local source build, inspect
+the CMake cache to check which options were configured:
.. code-block:: bash
- >>> python -c "import tvm; print('\n'.join(f'{k}: {v}' for k, v in
tvm.support.libinfo().items()))"
- ... # Omitted less relevant options
- GIT_COMMIT_HASH: 4f6289590252a1cf45a4dc37bce55a25043b8338
- HIDE_PRIVATE_SYMBOLS: ON
- USE_LLVM: llvm-config --link-static
- LLVM_VERSION: 15.0.7
- USE_VULKAN: OFF
- USE_CUDA: OFF
- CUDA_VERSION: NOT-FOUND
- USE_OPENCL: OFF
- USE_METAL: ON
- USE_ROCM: OFF
+ cmake -LA -N build
+
+The output includes parent ``TVM_USE_*`` options and the core's
+``TVM_TIRX_USE_*`` options. Keep ``build/CMakeCache.txt`` when reporting a
+configuration problem.
**Step 4. Check device detection.** Sometimes it could be helpful to
understand if TVM could detect your device at all with the following commands:
@@ -266,7 +252,7 @@ If you're building TVM on Windows, note these
platform-specific considerations:
Path Conventions
~~~~~~~~~~~~~~~~
- Use forward slashes (``/``) in Python/CMake paths, not Windows backslashes
-- Example: ``python cmake/config.cmake`` not ``python cmake\\config.cmake``
+- Example: ``-DCMAKE_TOOLCHAIN_FILE=C:/toolchains/windows.cmake``.
Advanced Build Configuration
----------------------------
@@ -277,7 +263,7 @@ On supported platforms, the `Ccache compiler wrapper
<https://ccache.dev/>`_ may
reducing TVM's build time, especially when building with `cutlass
<https://github.com/NVIDIA/cutlass>`_.
There are several ways to enable CCache in TVM builds:
- - Leave ``USE_CCACHE=AUTO`` in ``build/config.cmake``. CCache will be used
if it is found.
+ - Configure with ``-DTVM_USE_CCACHE=AUTO`` (the default). CCache will be
used if it is found.
- Ccache's Masquerade mode. This is typically enabled during the Ccache
installation process.
To have TVM use Ccache in masquerade, simply specify the appropriate
C/C++ compiler
@@ -319,7 +305,7 @@ For CUDA support on Windows:
set CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
set PATH=%CUDA_PATH%\bin;%PATH%
- cmake .. -DUSE_CUDA=ON
+ cmake .. -DTVM_TIRX_USE_CUDA=ON
CMake & Compiler Setup
......................
@@ -332,7 +318,7 @@ Building ROCm support
Currently, ROCm is supported only on linux, so all the instructions are
written with linux in mind.
-- Set ``set(TVM_TIRX_USE_ROCM ON)``, set TVM_TIRX_ROCM_PATH to the correct
path.
+- Configure with ``-DTVM_TIRX_USE_ROCM=ON`` or set it to the ROCm SDK path.
- You need to first install HIP runtime from ROCm. Make sure the installation
system has ROCm installed in it.
- Install LLVM (>= 15), and LLD, make sure ``ld.lld`` is available via command
line.
@@ -353,4 +339,4 @@ tests in TVM. The easiest way to install GTest is from
source.
make
sudo make install
-After installing GTest, the C++ tests can be built and started with
``./tests/scripts/task_cpp_unittest.sh``, or built via CMake with
``-DUSE_GTEST=ON`` and then running ``./build/cpptest``.
+After installing GTest, the C++ tests can be built and started with
``./tests/scripts/task_cpp_unittest.sh``, or built via CMake with
``-DTVM_USE_GTEST=ON`` and then running ``./build/cpptest``.
diff --git a/docs/tirx/install.rst b/docs/tirx/install.rst
index 0e76dd10ba..ad05a9b859 100644
--- a/docs/tirx/install.rst
+++ b/docs/tirx/install.rst
@@ -105,7 +105,7 @@ its bundled FFI dependency, then use native CMake options
(CMake 3.26 or newer):
Core feature options use the ``TVM_TIRX_USE_`` prefix. SDK selectors such as
``TVM_TIRX_USE_CUDA`` and ``TVM_TIRX_USE_LLVM`` also accept an SDK path or
``llvm-config`` command. Compiler caches, linkers, and toolchain flags use
-standard CMake settings. The standalone core does not read ``config.cmake``.
+standard CMake settings.
LLVM is enabled by default and requires LLVM 15 or newer with development
headers and libraries. Install ``llvm-dev`` on Debian/Ubuntu, ``llvm-devel``
@@ -137,7 +137,7 @@ The repository's native build script also accepts
``CMAKE_ARGS`` for its TVM
configuration, including parent-only options::
mkdir -p build
- CMAKE_ARGS='-DTVM_TIRX_USE_LLVM=ON -DUSE_RPC=ON' \
+ CMAKE_ARGS='-DTVM_TIRX_USE_LLVM=ON -DTVM_USE_RPC=ON' \
python tests/scripts/task_build.py --build-dir build
The native build script applies these settings only to TVM configuration;
diff --git a/jvm/core/src/main/java/org/apache/tvm/rpc/Client.java
b/jvm/core/src/main/java/org/apache/tvm/rpc/Client.java
index 4b20362c2a..5995deaaa9 100644
--- a/jvm/core/src/main/java/org/apache/tvm/rpc/Client.java
+++ b/jvm/core/src/main/java/org/apache/tvm/rpc/Client.java
@@ -34,7 +34,7 @@ public class Client {
public static RPCSession connect(String url, int port, String key) {
Function doConnect = RPC.getApi("Connect");
if (doConnect == null) {
- throw new RuntimeException("Please compile with USE_RPC=1");
+ throw new RuntimeException("Please compile with TVM_USE_RPC=1");
}
TVMValue sess = doConnect.pushArg(url).pushArg(port).pushArg(key).invoke();
return new RPCSession(sess.asModule());
diff --git a/python/tvm/relax/backend/contrib/example_npu/README.md
b/python/tvm/relax/backend/contrib/example_npu/README.md
index 310670fab1..769cc60c3b 100644
--- a/python/tvm/relax/backend/contrib/example_npu/README.md
+++ b/python/tvm/relax/backend/contrib/example_npu/README.md
@@ -43,14 +43,7 @@ This is an educational template that demonstrates real NPU
concepts without requ
Add the following flags when configuring TVM with CMake:
```bash
-cmake -DUSE_EXAMPLE_NPU_CODEGEN=ON -DUSE_EXAMPLE_NPU_RUNTIME=ON ..
-```
-
-Or set them in your `config.cmake`:
-
-```cmake
-set(USE_EXAMPLE_NPU_CODEGEN ON)
-set(USE_EXAMPLE_NPU_RUNTIME ON)
+cmake -DTVM_USE_EXAMPLE_NPU_CODEGEN=ON -DTVM_USE_EXAMPLE_NPU_RUNTIME=ON ..
```
## Quick Start
diff --git a/python/tvm/rpc/client.py b/python/tvm/rpc/client.py
index 69232a0ddb..9292f9de94 100644
--- a/python/tvm/rpc/client.py
+++ b/python/tvm/rpc/client.py
@@ -547,7 +547,7 @@ def connect(
raise TypeError("Expect the session constructor to be a list or
tuple")
sess = _ffi_api.Connect(url, port, key, enable_logging,
*session_constructor_args)
except NameError:
- raise RuntimeError("Please compile with USE_RPC=1")
+ raise RuntimeError("Please compile with TVM_USE_RPC=1")
return RPCSession(sess)
diff --git a/python/tvm/rpc/server.py b/python/tvm/rpc/server.py
index db077b7b4b..4d1de81167 100644
--- a/python/tvm/rpc/server.py
+++ b/python/tvm/rpc/server.py
@@ -512,9 +512,9 @@ class Server:
):
try:
if _ffi_api.ServerLoop is None:
- raise RuntimeError("Please compile with USE_RPC=1")
+ raise RuntimeError("Please compile with TVM_USE_RPC=1")
except NameError:
- raise RuntimeError("Please compile with USE_RPC=1")
+ raise RuntimeError("Please compile with TVM_USE_RPC=1")
self.proc = PopenWorker()
# send the function
self.proc.send(
diff --git a/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
b/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
index ba27115d9c..4795705aca 100644
--- a/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
+++ b/python/tvm/s_tir/meta_schedule/runner/rpc_runner.py
@@ -480,7 +480,7 @@ def default_alloc_argument(
f_random_fill = get_global_func_on_rpc_session(
session,
"tvm.contrib.random.random_fill_for_measure",
- "Please make sure 'USE_RANDOM' is turned ON in the config.cmake on the
RPC server.",
+ "Please make sure '-DTVM_USE_RANDOM=ON' is set when configuring CMake
on the RPC server.",
)
return alloc_argument_common(f_random_fill, device, args_info,
alloc_repeat, device.empty)
diff --git a/src/runtime/extra/contrib/clml/clml_runtime.cc
b/src/runtime/extra/contrib/clml/clml_runtime.cc
index e9f029afd9..c51677c35d 100644
--- a/src/runtime/extra/contrib/clml/clml_runtime.cc
+++ b/src/runtime/extra/contrib/clml/clml_runtime.cc
@@ -1947,12 +1947,12 @@ class CLMLRuntime : public JSONRuntimeBase {
#else
void Run() override {
TVM_FFI_THROW(InternalError) << "Cannot call run on CLML module without
runtime enabled. "
- << "Please build with
USE_CLML_GRAPH_EXECUTOR.";
+ << "Please build with
TVM_USE_CLML_GRAPH_EXECUTOR.";
}
void BuildEngine() {
LOG(WARNING) << "CLML engine is not initialized. "
- << "Please build with USE_CLML_GRAPH_EXECUTOR.";
+ << "Please build with TVM_USE_CLML_GRAPH_EXECUTOR.";
}
#endif
/*! CLML sub graph symbol in TVM main module */
diff --git a/src/runtime/extra/contrib/nnapi/nnapi_runtime.cc
b/src/runtime/extra/contrib/nnapi/nnapi_runtime.cc
index 83c2a70e7b..60fbf4ee0a 100644
--- a/src/runtime/extra/contrib/nnapi/nnapi_runtime.cc
+++ b/src/runtime/extra/contrib/nnapi/nnapi_runtime.cc
@@ -231,12 +231,12 @@ class NNAPIRuntime : public JSONRuntimeBase {
#else // ifdef TVM_GRAPH_EXECUTOR_NNAPI
void Init(const ffi::Array<ffi::Tensor>& consts) final {
TVM_FFI_THROW(InternalError)
- << "NNAPI runtime is not enabled. Build with USE_NNAPI_RUNTIME to
enable it.";
+ << "NNAPI runtime is not enabled. Build with TVM_USE_NNAPI_RUNTIME to
enable it.";
}
void Run() final {
TVM_FFI_THROW(InternalError)
- << "NNAPI runtime is not enabled. Build with USE_NNAPI_RUNTIME to
enable it.";
+ << "NNAPI runtime is not enabled. Build with TVM_USE_NNAPI_RUNTIME to
enable it.";
}
#endif // ifdef TVM_GRAPH_EXECUTOR_NNAPI
};
diff --git a/src/runtime/extra/contrib/tensorrt/tensorrt_runtime.cc
b/src/runtime/extra/contrib/tensorrt/tensorrt_runtime.cc
index 3fccb2d058..ab11f5a64b 100644
--- a/src/runtime/extra/contrib/tensorrt/tensorrt_runtime.cc
+++ b/src/runtime/extra/contrib/tensorrt/tensorrt_runtime.cc
@@ -753,12 +753,12 @@ class TensorRTRuntime : public JSONRuntimeBase {
#else // TVM_GRAPH_EXECUTOR_TENSORRT
void Run() override {
TVM_FFI_THROW(InternalError) << "TensorRT runtime is not enabled. "
- << "Please build with USE_TENSORRT_RUNTIME.";
+ << "Please build with
TVM_USE_TENSORRT_RUNTIME.";
}
void BuildEngine() {
LOG(WARNING) << "TensorRT runtime is not enabled. "
- << "Please build with USE_TENSORRT_RUNTIME.";
+ << "Please build with TVM_USE_TENSORRT_RUNTIME.";
}
void BuildEngineAtCompileTime(const ffi::Array<ffi::Tensor>& consts) {
@@ -766,7 +766,7 @@ class TensorRTRuntime : public JSONRuntimeBase {
TVM_FFI_ICHECK(tensor.defined());
}
TVM_FFI_THROW(InternalError)
- << "TensorRT build_at_compile_time requires TVM to be built with
USE_TENSORRT_RUNTIME";
+ << "TensorRT build_at_compile_time requires TVM to be built with
TVM_USE_TENSORRT_RUNTIME";
}
bool GetCachedEnginesFromDisk() { return false; }
diff --git a/src/runtime/extra/contrib/tensorrt/tensorrt_utils.h
b/src/runtime/extra/contrib/tensorrt/tensorrt_utils.h
index e0c06f018b..fc1b72fa08 100644
--- a/src/runtime/extra/contrib/tensorrt/tensorrt_utils.h
+++ b/src/runtime/extra/contrib/tensorrt/tensorrt_utils.h
@@ -36,7 +36,8 @@
// IExecutionContext::execute, obj->destroy(), ...). Emit a clear error
instead of a flood of
// "has no member" diagnostics on older releases.
#if !defined(NV_TENSORRT_MAJOR) || NV_TENSORRT_MAJOR < 10
-#error "TVM's TensorRT runtime requires TensorRT 10.0 or newer (or set
USE_TENSORRT_RUNTIME=OFF)."
+#error \
+ "TVM's TensorRT runtime requires TensorRT 10.0 or newer (or set
TVM_USE_TENSORRT_RUNTIME=OFF)."
#endif
// There is a conflict between cpplint and clang-format-10.
diff --git a/tests/cpp/CMakeLists.txt b/tests/cpp/CMakeLists.txt
index 45be2dee75..c3a23ec303 100644
--- a/tests/cpp/CMakeLists.txt
+++ b/tests/cpp/CMakeLists.txt
@@ -16,16 +16,16 @@
# under the License.
# Enable ctest if gtest is available
-if(USE_GTEST AND NOT BUILD_TESTING STREQUAL "OFF")
+if(TVM_USE_GTEST AND NOT BUILD_TESTING STREQUAL "OFF")
# Check env var for backward compatibility. A better way to specify package
# locations is to use CMAKE_PREFIX_PATH or other standard CMake mechanism
# (see CMake documentation for `find_package`).
set(GTEST_ROOT "$ENV{GTEST_LIB}")
- if("${USE_GTEST}" STREQUAL "AUTO")
- # If USE_GTEST is AUTO, treat GTest as optional: enable if found.
+ if("${TVM_USE_GTEST}" STREQUAL "AUTO")
+ # If TVM_USE_GTEST is AUTO, treat GTest as optional: enable if found.
find_package(GTest)
- elseif("${USE_GTEST}" MATCHES ${IS_TRUE_PATTERN})
- # USE_GTEST is set to ON, TRUE, etc. Treat GTest as a required package.
+ elseif("${TVM_USE_GTEST}" MATCHES ${IS_TRUE_PATTERN})
+ # TVM_USE_GTEST is set to ON, TRUE, etc. Treat GTest as a required package.
find_package(GTest REQUIRED)
endif()
if(GTEST_FOUND)
@@ -56,8 +56,9 @@ endif()
# Create the `cpptest` target when GTest is available.
if(GTEST_FOUND)
- tvm_file_glob(GLOB_RECURSE TEST_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
+ file(GLOB_RECURSE TEST_SRCS CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/*.cc")
add_executable(cpptest ${TEST_SRCS})
+ tvm_configure_target(cpptest)
# Preserve the executable location used before this became a subdirectory.
set_target_properties(cpptest PROPERTIES RUNTIME_OUTPUT_DIRECTORY
"${PROJECT_BINARY_DIR}")
# include runtime files for unit testing
@@ -77,7 +78,7 @@ if(GTEST_FOUND)
break()
endif()
endforeach()
- if(DEFINED LLVM_SO OR HIDE_PRIVATE_SYMBOLS)
+ if(DEFINED LLVM_SO OR TVM_HIDE_PRIVATE_SYMBOLS)
target_link_libraries(cpptest PRIVATE ${LLVM_LIBS})
endif()
endif()
diff --git a/tests/python/relax/test_tensorrt_engine_serialization.py
b/tests/python/relax/test_tensorrt_engine_serialization.py
index dea08cefc6..c1b1641998 100644
--- a/tests/python/relax/test_tensorrt_engine_serialization.py
+++ b/tests/python/relax/test_tensorrt_engine_serialization.py
@@ -149,7 +149,7 @@ def test_default_preserves_legacy_bytes():
@pytest.mark.skipif(_has_runtime, reason="This test requires a codegen-only
TensorRT build")
def test_eager_requires_runtime():
- with pytest.raises(RuntimeError, match="USE_TENSORRT_RUNTIME"):
+ with pytest.raises(RuntimeError, match="TVM_USE_TENSORRT_RUNTIME"):
_codegen(_relu_partition(), eager=True)
diff --git a/tests/scripts/release/test_release_package.sh
b/tests/scripts/release/test_release_package.sh
index 9effdd40ca..18ff858e0c 100644
--- a/tests/scripts/release/test_release_package.sh
+++ b/tests/scripts/release/test_release_package.sh
@@ -98,8 +98,7 @@ echo "[8/10] Compile and Python Import on Linux ..."
cd apache-tvm-src-${version}
mkdir build
cd build
-cp ../cmake/config.cmake .
-cmake ..
+cmake .. -DTVM_TIRX_USE_LLVM=OFF -DTVM_TIRX_USE_CUDA=OFF
make -j16
cd ..
diff --git a/tests/scripts/task_build_arm.sh b/tests/scripts/task_build_arm.sh
index c385fe0230..89291f86be 100755
--- a/tests/scripts/task_build_arm.sh
+++ b/tests/scripts/task_build_arm.sh
@@ -29,13 +29,12 @@ export CMAKE_ARGS="
-DTVM_FFI_BUILD_PYTHON_MODULE=ON
-DTVM_FFI_BUILD_TESTS=OFF
-DTVM_FFI_ATTACH_DEBUG_SYMBOLS=ON
- -DUSE_SORT=ON
- -DUSE_RPC=ON
+ -DTVM_USE_SORT=ON
+ -DTVM_USE_RPC=ON
-DCMAKE_CXX_FLAGS=-Werror
- -DUSE_CCACHE=OFF
- -DSUMMARIZE=ON
+ -DTVM_USE_CCACHE=OFF
-DTVM_USE_INSTALLED_TIRX=OFF
- -DUSE_GTEST=ON
+ -DTVM_USE_GTEST=ON
-DBUILD_TESTING=ON
-DTVM_TIRX_BUILD_TESTS=ON
-DTVM_TIRX_USE_LLVM=llvm-config-17
diff --git a/tests/scripts/task_build_cpu.sh b/tests/scripts/task_build_cpu.sh
index 732cedd360..38efddbebc 100755
--- a/tests/scripts/task_build_cpu.sh
+++ b/tests/scripts/task_build_cpu.sh
@@ -29,19 +29,15 @@ export CMAKE_ARGS="
-DTVM_FFI_BUILD_PYTHON_MODULE=ON
-DTVM_FFI_BUILD_TESTS=OFF
-DTVM_FFI_ATTACH_DEBUG_SYMBOLS=ON
- -DUSE_SORT=ON
- -DUSE_DNNL=ON
- -DUSE_EXAMPLE_NPU_CODEGEN=ON
- -DUSE_EXAMPLE_NPU_RUNTIME=ON
+ -DTVM_USE_SORT=ON
+ -DTVM_USE_DNNL=ON
+ -DTVM_USE_EXAMPLE_NPU_CODEGEN=ON
+ -DTVM_USE_EXAMPLE_NPU_RUNTIME=ON
-DCMAKE_CXX_FLAGS='-Wno-error=range-loop-construct -Wno-error=comment'
- -DHIDE_PRIVATE_SYMBOLS=ON
- -DUSE_TENSORFLOW_PATH=/tensorflow
- -DUSE_TFLITE=/opt/tflite
- -DUSE_FLATBUFFERS_PATH=/flatbuffers
- -DUSE_CCACHE=OFF
- -DSUMMARIZE=ON
+ -DTVM_HIDE_PRIVATE_SYMBOLS=ON
+ -DTVM_USE_CCACHE=OFF
-DTVM_USE_INSTALLED_TIRX=OFF
- -DUSE_GTEST=ON
+ -DTVM_USE_GTEST=ON
-DBUILD_TESTING=ON
-DTVM_TIRX_BUILD_TESTS=ON
-DTVM_TIRX_USE_LLVM='/usr/bin/llvm-config-17 --link-static'
diff --git a/tests/scripts/task_build_gpu.sh b/tests/scripts/task_build_gpu.sh
index 15df597dff..a2f9b3ea89 100755
--- a/tests/scripts/task_build_gpu.sh
+++ b/tests/scripts/task_build_gpu.sh
@@ -29,20 +29,19 @@ export CMAKE_ARGS="
-DTVM_FFI_BUILD_PYTHON_MODULE=ON
-DTVM_FFI_BUILD_TESTS=OFF
-DTVM_FFI_ATTACH_DEBUG_SYMBOLS=ON
- -DUSE_CUBLAS=ON
- -DUSE_CUDNN=ON
+ -DTVM_USE_CUBLAS=ON
+ -DTVM_USE_CUDNN=ON
-DTVM_TIRX_USE_CUDA=ON
- -DUSE_RPC=ON
- -DUSE_SORT=ON
- -DUSE_BLAS=openblas
+ -DTVM_USE_RPC=ON
+ -DTVM_USE_SORT=ON
+ -DTVM_USE_BLAS=openblas
-DCMAKE_CXX_FLAGS=-Werror
- -DUSE_TENSORRT_CODEGEN=ON
- -DHIDE_PRIVATE_SYMBOLS=ON
- -DUSE_CUTLASS=ON
+ -DTVM_USE_TENSORRT_CODEGEN=ON
+ -DTVM_HIDE_PRIVATE_SYMBOLS=ON
+ -DTVM_USE_CUTLASS=ON
-DCMAKE_CUDA_ARCHITECTURES=75
- -DUSE_CLML=ON
- -DUSE_CCACHE=OFF
- -DSUMMARIZE=ON
+ -DTVM_USE_CLML=ON
+ -DTVM_USE_CCACHE=OFF
-DTVM_USE_INSTALLED_TIRX=OFF
-DBUILD_TESTING=OFF
-DTVM_TIRX_BUILD_TESTS=OFF
diff --git a/tests/scripts/task_build_gpu_other.sh
b/tests/scripts/task_build_gpu_other.sh
index 59f33eaeac..6722ba232b 100755
--- a/tests/scripts/task_build_gpu_other.sh
+++ b/tests/scripts/task_build_gpu_other.sh
@@ -25,5 +25,5 @@ uv pip install --python python3 --no-deps --target
build/python ./tirx/3rdparty/
export PYTHONPATH="$PWD/build/python"
cmake -S . -B build -GNinja -DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DTVM_TIRX_USE_OPENCL=ON -DTVM_TIRX_USE_ROCM=ON -DCMAKE_CXX_FLAGS=-Werror \
- -DUSE_CCACHE=OFF -DSUMMARIZE=ON
+ -DTVM_USE_CCACHE=OFF
cmake --build build --target tvm_runtime tvm_runtime_opencl tvm_runtime_rocm
diff --git a/tests/scripts/task_build_wasm.sh b/tests/scripts/task_build_wasm.sh
index 0ea957c526..f9455d32af 100755
--- a/tests/scripts/task_build_wasm.sh
+++ b/tests/scripts/task_build_wasm.sh
@@ -29,14 +29,13 @@ export CMAKE_ARGS="
-DTVM_FFI_BUILD_PYTHON_MODULE=ON
-DTVM_FFI_BUILD_TESTS=OFF
-DTVM_FFI_ATTACH_DEBUG_SYMBOLS=ON
- -DUSE_SORT=ON
+ -DTVM_USE_SORT=ON
-DTVM_TIRX_USE_LLVM=llvm-config-15
-DCMAKE_CXX_FLAGS=-Werror
- -DHIDE_PRIVATE_SYMBOLS=ON
- -DUSE_CCACHE=OFF
- -DSUMMARIZE=ON
+ -DTVM_HIDE_PRIVATE_SYMBOLS=ON
+ -DTVM_USE_CCACHE=OFF
-DTVM_USE_INSTALLED_TIRX=OFF
- -DUSE_GTEST=ON
+ -DTVM_USE_GTEST=ON
-DBUILD_TESTING=ON
-DTVM_TIRX_BUILD_TESTS=ON
"