chore: import upstream snapshot with attribution
This commit is contained in:
@@ -0,0 +1,162 @@
|
||||
# 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.
|
||||
|
||||
# CUDA Module
|
||||
find_cuda(${USE_CUDA} ${USE_CUDNN})
|
||||
|
||||
if(CUDA_FOUND)
|
||||
# always set the includedir when CUDA is available
|
||||
# avoid global retrigger of CMake
|
||||
include_directories(SYSTEM ${CUDA_INCLUDE_DIRS})
|
||||
endif(CUDA_FOUND)
|
||||
|
||||
if(USE_CUDA)
|
||||
if(NOT CUDA_FOUND)
|
||||
message(FATAL_ERROR "Cannot find CUDA, USE_CUDA=" ${USE_CUDA})
|
||||
endif()
|
||||
message(STATUS "Build with CUDA ${CUDA_VERSION} support")
|
||||
enable_language(CUDA)
|
||||
|
||||
# Ensure that include directives to NVCC are in the
|
||||
# `compile_commands.json`, as required by clangd.
|
||||
#
|
||||
# As of CMake 3.29.5 [0], if the NVCC version is 11 or higher, CMake
|
||||
# will generate a "options-file.rsp" containing the -I flags for
|
||||
# include directories, rather than providing them on the
|
||||
# command-line. This setting exists to work around the short
|
||||
# command-line length limits on Windows, but is enabled on all
|
||||
# platforms. If set, because include directories are not part of
|
||||
# the `compile_commands.json`, the clangd LSP cannot find the
|
||||
# include files.
|
||||
#
|
||||
# Furthermore, this override cannot be specified in a user's
|
||||
# `config.cmake` for TVM, because it must be set after CMake's
|
||||
# built-in CUDA support.
|
||||
#
|
||||
# [0] https://github.com/Kitware/CMake/commit/6377a438
|
||||
set(CMAKE_CUDA_USE_RESPONSE_FILE_FOR_INCLUDES 0)
|
||||
|
||||
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
|
||||
if(CMAKE_VERSION VERSION_LESS "3.24")
|
||||
message(FATAL_ERROR "CMAKE_CUDA_ARCHITECTURES not set. Please upgrade CMake to 3.24 to use native, or set CMAKE_CUDA_ARCHITECTURES manually")
|
||||
endif()
|
||||
message(STATUS "CMAKE_CUDA_ARCHITECTURES not set, using native")
|
||||
set(CMAKE_CUDA_ARCHITECTURES native)
|
||||
endif()
|
||||
endif(USE_CUDA)
|
||||
|
||||
if(USE_CUDA)
|
||||
message(STATUS "Build cuda device runtime")
|
||||
|
||||
# tvm_runtime_cuda links libcuda; without it the .so silently drops its
|
||||
# libcuda.so.1 dependency, so fail configure instead.
|
||||
if(NOT CUDA_CUDA_LIBRARY)
|
||||
message(FATAL_ERROR "USE_CUDA is on but libcuda was not found. "
|
||||
"Set -DCUDA_CUDA_LIBRARY=<path to libcuda.so> or make the driver stub discoverable.")
|
||||
endif()
|
||||
|
||||
tvm_file_glob(GLOB RUNTIME_CUDA_SRCS src/backend/cuda/runtime/*.cc)
|
||||
tvm_file_glob(GLOB VM_CUDA_BUILTIN_SRC_CC src/runtime/vm/cuda/*.cc)
|
||||
|
||||
add_library(tvm_runtime_cuda_objs OBJECT ${RUNTIME_CUDA_SRCS} ${VM_CUDA_BUILTIN_SRC_CC})
|
||||
target_link_libraries(tvm_runtime_cuda_objs PUBLIC tvm_ffi_header)
|
||||
# These sources compile into tvm_runtime_cuda.dll, so their TVM_RUNTIME_DLL /
|
||||
# TVM_FFI_DLL symbols must be dllexport on MSVC (e.g. GetCudaDeviceCount in
|
||||
# cuda_device_api.cc). Mirror tvm_runtime_objs; a no-op on non-MSVC platforms.
|
||||
target_compile_definitions(tvm_runtime_cuda_objs PRIVATE TVM_RUNTIME_EXPORTS TVM_FFI_EXPORTS)
|
||||
set_target_properties(tvm_runtime_cuda_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(TVM_VISIBILITY_FLAG)
|
||||
target_compile_options(tvm_runtime_cuda_objs PRIVATE "${TVM_VISIBILITY_FLAG}")
|
||||
endif()
|
||||
add_library(tvm_runtime_cuda SHARED $<TARGET_OBJECTS:tvm_runtime_cuda_objs>)
|
||||
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_cuda)
|
||||
target_link_libraries(tvm_runtime_cuda PUBLIC tvm_runtime ${CUDA_CUDART_LIBRARY} ${CUDA_CUDA_LIBRARY})
|
||||
tvm_configure_target_library(tvm_runtime_cuda RUNTIME_MODULE)
|
||||
|
||||
if(USE_NVTX)
|
||||
message(STATUS "Build with NVTX support")
|
||||
target_link_libraries(tvm_runtime_cuda PRIVATE ${CUDA_NVTX_LIBRARY})
|
||||
endif()
|
||||
endif(USE_CUDA)
|
||||
|
||||
# Contrib sources gated by USE_CUDA go into libtvm_runtime_extra.
|
||||
# See the RuntimeExtra assembly block in CMakeLists.txt.
|
||||
|
||||
if(USE_CUDA AND 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)
|
||||
list(APPEND COMPILER_SRCS ${CUDNN_RELAX_CONTRIB_SRC})
|
||||
tvm_file_glob(GLOB CONTRIB_CUDNN_SRCS src/runtime/extra/contrib/cudnn/*.cc)
|
||||
add_library(tvm_cudnn_objs OBJECT ${CONTRIB_CUDNN_SRCS})
|
||||
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(USE_CUDA AND USE_CUDNN)
|
||||
|
||||
if(USE_CUDA AND 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)
|
||||
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")
|
||||
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})
|
||||
target_link_libraries(tvm_cudnn_frontend_objs PRIVATE tvm_runtime_extra_defs)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_cudnn_frontend_objs)
|
||||
endif(USE_CUDA AND USE_CUDNN_FRONTEND)
|
||||
|
||||
if(USE_CUDA AND USE_CUBLAS)
|
||||
message(STATUS "Build with cuBLAS support")
|
||||
tvm_file_glob(GLOB CUBLAS_CONTRIB_SRC 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)
|
||||
add_library(tvm_cublas_objs OBJECT ${CONTRIB_CUBLAS_SRCS})
|
||||
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(USE_CUDA AND USE_CUBLAS)
|
||||
|
||||
if(USE_CUDA AND USE_THRUST)
|
||||
message(STATUS "Build with Thrust support")
|
||||
tvm_file_glob(GLOB CONTRIB_THRUST_SRC src/runtime/extra/contrib/thrust/*.cu)
|
||||
add_library(tvm_thrust_objs OBJECT ${CONTRIB_THRUST_SRC})
|
||||
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)
|
||||
target_link_libraries(tvm_thrust_objs PRIVATE CCCL::Thrust)
|
||||
endif()
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_thrust_objs)
|
||||
endif(USE_CUDA AND USE_THRUST)
|
||||
|
||||
if(USE_CUDA AND 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)
|
||||
add_library(tvm_curand_objs OBJECT ${CONTRIB_CURAND_SRC_CC} ${CONTRIB_CURAND_SRC_CU})
|
||||
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(USE_CUDA AND USE_CURAND)
|
||||
@@ -0,0 +1,90 @@
|
||||
# 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.
|
||||
|
||||
# If we are running clang >= 10.0 then enable more checking. Some of these warnings may not exist
|
||||
# in older versions of clang so we limit the use of older clang for these checks.
|
||||
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
EXECUTE_PROCESS(COMMAND ${CMAKE_CXX_COMPILER} --version OUTPUT_VARIABLE clang_full_version)
|
||||
string (REGEX REPLACE ".*clang version ([0-9]+\\.[0-9]+).*" "\\1" CLANG_VERSION ${clang_full_version})
|
||||
message(STATUS "CLANG_VERSION ${CLANG_VERSION}")
|
||||
# CMake 3.2 does not support VERSION_GREATER_EQUAL
|
||||
set(CLANG_MINIMUM_VERSION 10.0)
|
||||
if ((CLANG_VERSION VERSION_GREATER ${CLANG_MINIMUM_VERSION})
|
||||
OR
|
||||
(CLANG_VERSION VERSION_GREATER ${CLANG_MINIMUM_VERSION}))
|
||||
message(STATUS "Setting enhanced clang warning flags")
|
||||
|
||||
set(warning_opts
|
||||
# These warnings are only enabled when clang's -Weverything flag is enabled
|
||||
# but there is no harm in turning them off for all cases.
|
||||
-Wno-c++98-compat
|
||||
-Wno-c++98-compat-extra-semi
|
||||
-Wno-c++98-compat-pedantic
|
||||
-Wno-padded
|
||||
-Wno-extra-semi
|
||||
-Wno-extra-semi-stmt
|
||||
-Wno-unused-parameter
|
||||
-Wno-sign-conversion
|
||||
-Wno-weak-vtables
|
||||
-Wno-deprecated-copy-dtor
|
||||
-Wno-global-constructors
|
||||
-Wno-double-promotion
|
||||
-Wno-float-equal
|
||||
-Wno-missing-prototypes
|
||||
-Wno-implicit-int-float-conversion
|
||||
-Wno-implicit-float-conversion
|
||||
-Wno-implicit-int-conversion
|
||||
-Wno-float-conversion
|
||||
-Wno-shorten-64-to-32
|
||||
-Wno-covered-switch-default
|
||||
-Wno-unused-exception-parameter
|
||||
-Wno-return-std-move
|
||||
-Wno-over-aligned
|
||||
-Wno-undef
|
||||
-Wno-inconsistent-missing-destructor-override
|
||||
-Wno-unreachable-code
|
||||
-Wno-deprecated-copy
|
||||
-Wno-implicit-fallthrough
|
||||
-Wno-unreachable-code-return
|
||||
-Wno-non-virtual-dtor
|
||||
# Here we have non-standard warnings that clang has available and are useful
|
||||
# so enable them if we are using clang.
|
||||
-Wreserved-id-macro
|
||||
-Wused-but-marked-unused
|
||||
-Wdocumentation-unknown-command
|
||||
-Wcast-qual
|
||||
-Wzero-as-null-pointer-constant
|
||||
# These warnings should be enabled one at a time and fixed.
|
||||
# To enable one of these warnings remove the `no-` after -W so
|
||||
# -Wno-documentation -> -Wdocumentation
|
||||
-Wno-documentation
|
||||
-Wno-shadow-uncaptured-local
|
||||
-Wno-shadow-field-in-constructor
|
||||
-Wno-shadow
|
||||
-Wno-shadow-field
|
||||
-Wno-exit-time-destructors
|
||||
-Wno-switch-enum
|
||||
-Wno-old-style-cast
|
||||
-Wno-gnu-anonymous-struct
|
||||
-Wno-nested-anon-types
|
||||
)
|
||||
target_compile_options(tvm_objs PRIVATE $<$<COMPILE_LANGUAGE:CXX>: ${warning_opts}>)
|
||||
target_compile_options(tvm_runtime_objs PRIVATE $<$<COMPILE_LANGUAGE:CXX>: ${warning_opts}>)
|
||||
|
||||
|
||||
endif ()
|
||||
endif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
||||
@@ -0,0 +1,56 @@
|
||||
# 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.
|
||||
|
||||
# This script provides
|
||||
# - GIT_FOUND - true if the command line client was found
|
||||
# - GIT_EXECUTABLE - path to git command line client
|
||||
# - TVM_GIT_COMMIT_HASH - The git commit hash found, or "NOT-FOUND" if anything went wrong
|
||||
# - TVM_GIT_COMMIT_TIME - The git commit time, or "NOT-FOUND" if antything went wrong
|
||||
find_package(Git QUIET)
|
||||
if (${GIT_FOUND})
|
||||
message(STATUS "Git found: ${GIT_EXECUTABLE}")
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse HEAD
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE TVM_GIT_COMMIT_HASH
|
||||
RESULT_VARIABLE _TVM_GIT_RESULT
|
||||
ERROR_VARIABLE _TVM_GIT_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if (${_TVM_GIT_RESULT} EQUAL 0)
|
||||
message(STATUS "Found TVM_GIT_COMMIT_HASH=${TVM_GIT_COMMIT_HASH}")
|
||||
else()
|
||||
message(STATUS "Not a git repo")
|
||||
set(TVM_GIT_COMMIT_HASH "NOT-FOUND")
|
||||
endif()
|
||||
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --format=%ci HEAD
|
||||
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
|
||||
OUTPUT_VARIABLE TVM_GIT_COMMIT_TIME
|
||||
RESULT_VARIABLE _TVM_GIT_RESULT
|
||||
ERROR_VARIABLE _TVM_GIT_ERROR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE)
|
||||
if (${_TVM_GIT_RESULT} EQUAL 0)
|
||||
message(STATUS "Found TVM_GIT_COMMIT_TIME=${TVM_GIT_COMMIT_TIME}")
|
||||
else()
|
||||
set(TVM_GIT_COMMIT_TIME "NOT-FOUND")
|
||||
endif()
|
||||
else()
|
||||
message(WARNING "Git not found")
|
||||
set(TVM_GIT_COMMIT_HASH "NOT-FOUND")
|
||||
set(TVM_GIT_COMMIT_TIME "NOT-FOUND")
|
||||
endif()
|
||||
@@ -0,0 +1,351 @@
|
||||
# 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.
|
||||
|
||||
include(ExternalProject)
|
||||
include(cmake/modules/HexagonSDK.cmake)
|
||||
|
||||
set(FOUND_HEXAGON_TOOLCHAIN FALSE)
|
||||
|
||||
function(find_hexagon_toolchain)
|
||||
if(FOUND_HEXAGON_TOOLCHAIN)
|
||||
return()
|
||||
endif()
|
||||
if(NOT "${USE_HEXAGON_TOOLCHAIN}" STREQUAL "")
|
||||
set(TRY_PATH "${USE_HEXAGON_TOOLCHAIN}")
|
||||
else()
|
||||
set(TRY_PATH "${USE_HEXAGON_SDK}")
|
||||
endif()
|
||||
message(STATUS "Looking for Hexagon toolchain in ${TRY_PATH}")
|
||||
file(GLOB_RECURSE HEXAGON_CLANG "${TRY_PATH}/*/hexagon-clang++")
|
||||
if(HEXAGON_CLANG)
|
||||
# The path is ${HEXAGON_TOOLCHAIN}/bin/hexagon-clang++.
|
||||
get_filename_component(HEXAGON_TMP0 "${HEXAGON_CLANG}" DIRECTORY)
|
||||
get_filename_component(HEXAGON_TMP1 "${HEXAGON_TMP0}" DIRECTORY)
|
||||
set(HEXAGON_TOOLCHAIN "${HEXAGON_TMP1}" CACHE PATH
|
||||
"Path to the Hexagon toolchain")
|
||||
set(FOUND_HEXAGON_TOOLCHAIN TRUE)
|
||||
else()
|
||||
message(SEND_ERROR "Cannot find Hexagon toolchain in ${TRY_PATH}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
macro(file_glob_append _output_list)
|
||||
tvm_file_glob(GLOB _tmp0 ${ARGN})
|
||||
set(_tmp1 ${${_output_list}})
|
||||
list(APPEND _tmp1 ${_tmp0})
|
||||
set(${_output_list} ${_tmp1})
|
||||
endmacro()
|
||||
|
||||
set(TVMRT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/backend/hexagon/runtime")
|
||||
set(TVM_CORE_RUNTIME_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src/runtime")
|
||||
|
||||
if(DEFINED USE_HEXAGON_DEVICE)
|
||||
message(WARNING "USE_HEXAGON_DEVICE is deprecated, use USE_HEXAGON instead")
|
||||
endif()
|
||||
|
||||
# This .cmake file is included when building any part of TVM for any
|
||||
# architecture. It shouldn't require any Hexagon-specific parameters (like
|
||||
# the path to the SDK), unless it's needed. The flag USE_HEXAGON decides
|
||||
# whether any Hexagon-related functionality is enabled. Specifically,
|
||||
# setting USE_HEXAGON=OFF, disables any form of Hexagon support.
|
||||
#
|
||||
# Note on the function of USE_HEXAGON_RPC:
|
||||
# - When building for Hexagon, this will build the Hexagon endpoint of the
|
||||
# RPC server: the FastRPC skel library (with TVM runtime built into it),
|
||||
# and the standalone RPC server for simulator.
|
||||
# - When building for Android, this will build the (intermediary) RPC server,
|
||||
# including the "stub" code for the FastRPC implementation of the RPC
|
||||
# channel.
|
||||
# - When building for x86, this will build the host-side code that instan-
|
||||
# tiates the simulator.
|
||||
|
||||
if(NOT BUILD_FOR_HEXAGON AND NOT BUILD_FOR_ANDROID)
|
||||
set(BUILD_FOR_HOST TRUE)
|
||||
endif()
|
||||
|
||||
|
||||
if(NOT USE_HEXAGON)
|
||||
# USE_HEXAGON=OFF: codegen still works through the per-backend fallback
|
||||
# module (src/backend/hexagon/codegen/hexagon_fallback_module.cc), which is always
|
||||
# compiled into libtvm via CODEGEN_SRCS. No opt-stub registration is
|
||||
# needed.
|
||||
return()
|
||||
endif()
|
||||
|
||||
# From here on, USE_HEXAGON is assumed to be TRUE.
|
||||
|
||||
if(BUILD_FOR_HOST AND USE_HEXAGON_QHL)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DENABLE_QHL")
|
||||
endif()
|
||||
|
||||
function(add_android_paths)
|
||||
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
|
||||
SDK_INCLUDE SDK_INCLUDE_DIRS
|
||||
DSPRPC_LIB DSPRPC_LIB_DIRS
|
||||
RPCMEM_ROOT RPCMEM_ROOT_DIR
|
||||
)
|
||||
if(NOT SDK_INCLUDE_DIRS OR NOT DSPRPC_LIB_DIRS OR NOT RPCMEM_ROOT_DIR)
|
||||
message(WARNING "Could not locate some Hexagon SDK components")
|
||||
endif()
|
||||
|
||||
include_directories(SYSTEM
|
||||
${SDK_INCLUDE_DIRS}
|
||||
"${RPCMEM_ROOT_DIR}/inc"
|
||||
)
|
||||
link_directories(${DSPRPC_LIB_DIRS})
|
||||
endfunction()
|
||||
|
||||
function(add_hexagon_wrapper_paths)
|
||||
if(NOT DEFINED HEXAGON_TOOLCHAIN)
|
||||
message(FATAL_ERROR "This function must be called after find_hexagon_toolchain")
|
||||
endif()
|
||||
include_directories(SYSTEM
|
||||
"${HEXAGON_TOOLCHAIN}/include/iss"
|
||||
)
|
||||
link_directories("${HEXAGON_TOOLCHAIN}/lib/iss")
|
||||
endfunction()
|
||||
|
||||
if(BUILD_FOR_HEXAGON)
|
||||
# When building FOR Hexagon (the DSP itself), all runtime sources go into
|
||||
# the single libtvm_runtime (static or shared). No per-backend DSO split.
|
||||
file_glob_append(RUNTIME_HEXAGON_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/*.cc"
|
||||
)
|
||||
# Add builtins to RelaxVM
|
||||
tvm_file_glob(GLOB VM_BUILTIN_SRC_CC src/runtime/vm/hexagon/*.cc)
|
||||
list(APPEND RUNTIME_SRCS ${VM_BUILTIN_SRC_CC})
|
||||
else()
|
||||
file_glob_append(RUNTIME_HEXAGON_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/hexagon_module.cc"
|
||||
)
|
||||
endif()
|
||||
|
||||
set(htp_supported_archs "v68" "v69" "v73" "v75")
|
||||
list(FIND htp_supported_archs "${USE_HEXAGON_ARCH}" supported_arch_index)
|
||||
if(${supported_arch_index} EQUAL -1)
|
||||
# Exclude User DMA files when building for archs below v68
|
||||
list(REMOVE_ITEM RUNTIME_HEXAGON_SRCS "${TVMRT_SOURCE_DIR}/hexagon_user_dma.cc")
|
||||
endif()
|
||||
|
||||
if(BUILD_FOR_HEXAGON)
|
||||
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
|
||||
SDK_INCLUDE SDK_INCLUDE_DIRS
|
||||
QURT_INCLUDE QURT_INCLUDE_DIRS
|
||||
)
|
||||
if(NOT SDK_INCLUDE_DIRS OR NOT QURT_INCLUDE_DIRS)
|
||||
message(WARNING "Could not locate some Hexagon SDK components")
|
||||
endif()
|
||||
|
||||
# Set the compiler arch flag.
|
||||
add_definitions("-m${USE_HEXAGON_ARCH}")
|
||||
|
||||
# Add SDK and QuRT includes when building for Hexagon.
|
||||
include_directories(SYSTEM ${SDK_INCLUDE_DIRS} ${QURT_INCLUDE_DIRS})
|
||||
|
||||
set(USE_CUSTOM_LOGGING ON) # To use a custom logger
|
||||
|
||||
# QHL support.
|
||||
if(USE_HEXAGON_QHL)
|
||||
file_glob_append(TVM_QHL_WRAPPER_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/qhl/*.cc"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${USE_HEXAGON_SDK}/libs/qhl_hvx/inc/qhmath_hvx"
|
||||
"${USE_HEXAGON_SDK}/libs/qhl_hvx/inc/internal/"
|
||||
|
||||
"${USE_HEXAGON_SDK}/libs/qhl/inc/qhmath"
|
||||
"${USE_HEXAGON_SDK}/libs/qhl/src/internal/"
|
||||
)
|
||||
set_property(SOURCE ${TVM_QHL_WRAPPER_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS "-Wno-narrowing -mhvx -mhvx-length=128B")
|
||||
|
||||
list(APPEND TVM_RUNTIME_LINKER_LIBS -Wl,--whole-archive ${USE_HEXAGON_SDK}/libs/qhl_hvx/prebuilt/hexagon_toolv84_v68/libqhmath_hvx.a -Wl,--no-whole-archive)
|
||||
list(APPEND TVM_RUNTIME_LINKER_LIBS -Wl,--whole-archive ${USE_HEXAGON_SDK}/libs/qhl/prebuilt/hexagon_toolv84_v68/libqhmath.a -Wl,--no-whole-archive)
|
||||
|
||||
endif()
|
||||
|
||||
# Exclude HVX implementation files when building for archs below v68
|
||||
if(${supported_arch_index} GREATER -1)
|
||||
# Hand-written ops
|
||||
file_glob_append(RUNTIME_HEXAGON_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/ops/*.cc"
|
||||
)
|
||||
|
||||
include_directories(
|
||||
"${TVMRT_SOURCE_DIR}/ops"
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
"${TVMRT_SOURCE_DIR}/ops/conv2d_quant_hvx.cc"
|
||||
PROPERTIES COMPILE_FLAGS "-mhvx"
|
||||
)
|
||||
|
||||
set_source_files_properties(
|
||||
"${TVMRT_SOURCE_DIR}/ops/conv2d_fp16_hvx.cc"
|
||||
PROPERTIES COMPILE_FLAGS "-mhvx"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Include hexagon external library runtime sources
|
||||
if(USE_HEXAGON_EXTERNAL_LIBS)
|
||||
# Check if the libs are provided as an absolute path
|
||||
if(EXISTS ${USE_HEXAGON_EXTERNAL_LIBS})
|
||||
# Check if the libs are provided as a git url
|
||||
elseif(USE_HEXAGON_EXTERNAL_LIBS MATCHES "\.git$")
|
||||
if(NOT DEFINED HEXAGON_EXTERNAL_LIBS_SHA)
|
||||
message(FATAL_ERROR "HEXAGON_EXTERNA_LIBS_SHA must be set when "
|
||||
"USE_HEXAGON_EXTERNAL_LIBS is set to a git repository")
|
||||
endif()
|
||||
include(FetchContent)
|
||||
FetchContent_Declare(hexagon_external
|
||||
GIT_REPOSITORY "${USE_HEXAGON_EXTERNAL_LIBS}"
|
||||
GIT_TAG "${HEXAGON_EXTERNAL_LIBS_SHA}")
|
||||
FetchContent_MakeAvailable(hexagon_external)
|
||||
set(USE_HEXAGON_EXTERNAL_LIBS "${hexagon_external_SOURCE_DIR}")
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid use of USE_HEXAGON_EXTERNAL_LIBS="
|
||||
"${USE_HEXAGON_EXTERNAL_LIBS}; USE_HEXAGON_EXTERNAL_LIBS only "
|
||||
"supports absolute paths and git repository urls")
|
||||
endif()
|
||||
|
||||
file_glob_append(HEXAGON_EXTERNAL_RUNTIME_SRCS
|
||||
"${USE_HEXAGON_EXTERNAL_LIBS}/src/runtime/hexagon/*.cc"
|
||||
)
|
||||
list(APPEND RUNTIME_HEXAGON_SRCS "${HEXAGON_EXTERNAL_RUNTIME_SRCS}")
|
||||
if(EXISTS "${USE_HEXAGON_EXTERNAL_LIBS}/HexagonExternalCompileFlags.cmake")
|
||||
# External libraries will define HEXAGON_EXTERNAL_LIBS_COMPILE_FLAGS,
|
||||
# changing this variable name will break downstream external libraries.
|
||||
include("${USE_HEXAGON_EXTERNAL_LIBS}/HexagonExternalCompileFlags.cmake")
|
||||
set_source_files_properties(
|
||||
"${HEXAGON_EXTERNAL_RUNTIME_SRCS}"
|
||||
PROPERTIES COMPILE_FLAGS "${HEXAGON_EXTERNAL_LIBS_COMPILE_FLAGS}"
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(USE_HEXAGON_RPC)
|
||||
function(build_rpc_idl)
|
||||
get_hexagon_sdk_property("${USE_HEXAGON_SDK}" "${USE_HEXAGON_ARCH}"
|
||||
SDK_INCLUDE SDK_INCLUDE_DIRS
|
||||
QAIC_EXE QAIC_EXE_PATH
|
||||
)
|
||||
foreach(INCDIR IN LISTS SDK_INCLUDE_DIRS)
|
||||
list(APPEND QAIC_FLAGS "-I${INCDIR}")
|
||||
endforeach()
|
||||
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc.h"
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc_skel.c"
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc_stub.c"
|
||||
COMMAND
|
||||
${QAIC_EXE_PATH} ${QAIC_FLAGS}
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc.idl"
|
||||
-o "${TVMRT_SOURCE_DIR}/rpc"
|
||||
MAIN_DEPENDENCY "${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc.idl"
|
||||
)
|
||||
|
||||
if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang")
|
||||
# We can't easily fix this at the source-code level, because the .c file is generated
|
||||
# by the qaic program. But it should be safe to ignore the warning:
|
||||
# https://stackoverflow.com/questions/13905200/is-it-wise-to-ignore-gcc-clangs-wmissing-braces-warning
|
||||
set_source_files_properties("${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc_stub.c"
|
||||
PROPERTY COMPILE_FLAGS "-Wno-missing-braces")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
if(BUILD_FOR_ANDROID)
|
||||
# Android part
|
||||
add_android_paths()
|
||||
build_rpc_idl()
|
||||
file_glob_append(RUNTIME_HEXAGON_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/rpc/android/*.cc"
|
||||
)
|
||||
# Add this file separately, because it's auto-generated, and glob won't
|
||||
# find it during cmake-time.
|
||||
list(APPEND RUNTIME_HEXAGON_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc_stub.c"
|
||||
)
|
||||
list(APPEND TVM_RUNTIME_LINKER_LIBS cdsprpc)
|
||||
|
||||
elseif(BUILD_FOR_HEXAGON)
|
||||
# Hexagon part
|
||||
find_hexagon_toolchain()
|
||||
build_rpc_idl()
|
||||
|
||||
# Include the generic RPC code into the TVM runtime.
|
||||
list(APPEND RUNTIME_HEXAGON_SRCS
|
||||
"${TVM_CORE_RUNTIME_SOURCE_DIR}/rpc/minrpc/minrpc_server.h"
|
||||
"${TVM_CORE_RUNTIME_SOURCE_DIR}/rpc/minrpc/rpc_reference.h"
|
||||
"${TVM_CORE_RUNTIME_SOURCE_DIR}/rpc/rpc_module.cc"
|
||||
"${TVM_CORE_RUNTIME_SOURCE_DIR}/rpc/rpc_endpoint.cc"
|
||||
"${TVM_CORE_RUNTIME_SOURCE_DIR}/rpc/rpc_session.cc"
|
||||
# TODO(masahi): Remove rpc_local_session.cc after verifying that things work without it
|
||||
"${TVM_CORE_RUNTIME_SOURCE_DIR}/rpc/rpc_local_session.cc"
|
||||
)
|
||||
set(HEXAGON_PROFILER_DIR "${TVMRT_SOURCE_DIR}/profiler")
|
||||
# Add the hardware-specific RPC code into the skel library.
|
||||
set_property(SOURCE ${HEXAGON_PROFILER_DIR}/lwp_handler.S PROPERTY LANGUAGE C)
|
||||
add_library(hexagon_rpc_skel SHARED
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon/rpc_server.cc"
|
||||
"${TVMRT_SOURCE_DIR}/rpc/hexagon_rpc_skel.c"
|
||||
"${HEXAGON_PROFILER_DIR}/prof_utils.cc"
|
||||
"${HEXAGON_PROFILER_DIR}/lwp_handler.S"
|
||||
)
|
||||
target_include_directories(hexagon_rpc_skel
|
||||
SYSTEM PRIVATE "${TVMRT_SOURCE_DIR}/rpc"
|
||||
)
|
||||
# Add the simulator-specific RPC code into a shared library to be
|
||||
# executed via run_main_on_sim.
|
||||
add_library(hexagon_rpc_sim SHARED
|
||||
"${TVMRT_SOURCE_DIR}/rpc/simulator/rpc_server.cc"
|
||||
"${HEXAGON_PROFILER_DIR}/prof_utils.cc"
|
||||
"${HEXAGON_PROFILER_DIR}/lwp_handler.S"
|
||||
)
|
||||
target_link_libraries(hexagon_rpc_sim
|
||||
-Wl,--whole-archive tvm_runtime -Wl,--no-whole-archive
|
||||
)
|
||||
|
||||
elseif(BUILD_FOR_HOST)
|
||||
find_hexagon_toolchain()
|
||||
add_hexagon_wrapper_paths()
|
||||
file_glob_append(RUNTIME_HEXAGON_SRCS
|
||||
"${TVMRT_SOURCE_DIR}/rpc/simulator/session.cc"
|
||||
)
|
||||
list(APPEND TVM_RUNTIME_LINKER_LIBS "-lwrapper")
|
||||
endif()
|
||||
endif() # USE_HEXAGON_RPC
|
||||
|
||||
# When building for the Hexagon DSP itself, all sources fold into
|
||||
# libtvm_runtime (static/shared). When building for a host with
|
||||
# USE_HEXAGON=ON, create a separate libtvm_runtime_hexagon.so.
|
||||
if(BUILD_FOR_HEXAGON)
|
||||
list(APPEND RUNTIME_SRCS ${RUNTIME_HEXAGON_SRCS} ${TVM_QHL_WRAPPER_SRCS})
|
||||
elseif(USE_HEXAGON)
|
||||
message(STATUS "Build hexagon device runtime")
|
||||
add_library(tvm_runtime_hexagon_objs OBJECT ${RUNTIME_HEXAGON_SRCS} ${TVM_QHL_WRAPPER_SRCS})
|
||||
target_link_libraries(tvm_runtime_hexagon_objs PUBLIC tvm_ffi_header)
|
||||
set_target_properties(tvm_runtime_hexagon_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(TVM_VISIBILITY_FLAG)
|
||||
target_compile_options(tvm_runtime_hexagon_objs PRIVATE "${TVM_VISIBILITY_FLAG}")
|
||||
endif()
|
||||
add_library(tvm_runtime_hexagon SHARED $<TARGET_OBJECTS:tvm_runtime_hexagon_objs>)
|
||||
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_hexagon)
|
||||
target_link_libraries(tvm_runtime_hexagon PUBLIC tvm_runtime)
|
||||
tvm_configure_target_library(tvm_runtime_hexagon RUNTIME_MODULE)
|
||||
endif()
|
||||
@@ -0,0 +1,205 @@
|
||||
# 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.
|
||||
|
||||
macro(set_parent _var)
|
||||
set(${_var} ${ARGN} PARENT_SCOPE)
|
||||
endmacro()
|
||||
|
||||
# Check if the path in _path exists. If true, set _output_variable
|
||||
# to the absolute path, otherwise set it to the value of _path with
|
||||
# the suffix "-NOTFOUND" appended to it.
|
||||
function(_check_path_exists _path _output_variable)
|
||||
file(TO_NATIVE_PATH "/" _native_root_dir)
|
||||
file(RELATIVE_PATH _absolute_path "${_native_root_dir}" "${_path}")
|
||||
# RELATIVE_PATH will strip the root, so add it back.
|
||||
set(_absolute_path "${_native_root_dir}${_absolute_path}")
|
||||
if(EXISTS "${_absolute_path}")
|
||||
set_parent(${_output_variable} "${_absolute_path}")
|
||||
else()
|
||||
set_parent(${_output_variable} "${_path}-NOTFOUND")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Check if all paths in the _paths list exist. If so set _output_variable
|
||||
# to the list of the absolute paths from the input list, otherwise set
|
||||
# _output_variable to the first path that was not found, and append the
|
||||
# "-NOTFOUND" suffix to it.
|
||||
function(_check_all_paths_exist _paths _output_variable)
|
||||
foreach(_path IN LISTS _paths)
|
||||
_check_path_exists("${_path}" _out_path)
|
||||
if(_out_path)
|
||||
list(APPEND _out_paths "${_out_path}")
|
||||
else()
|
||||
set_parent(${_output_variable} "${_path}-NOTFOUND")
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
set_parent(${_output_variable} ${_out_paths})
|
||||
endfunction()
|
||||
|
||||
function(_get_linux_version _output_vendor _output_release)
|
||||
execute_process(
|
||||
COMMAND lsb_release "-is"
|
||||
OUTPUT_VARIABLE _vendor
|
||||
)
|
||||
if(_vendor)
|
||||
string(STRIP "${_vendor}" _vendor)
|
||||
set_parent(${_output_vendor} ${_vendor})
|
||||
else()
|
||||
set_parent(${_output_vendor} "NOTFOUND")
|
||||
endif()
|
||||
execute_process(
|
||||
COMMAND lsb_release "-rs"
|
||||
OUTPUT_VARIABLE _release
|
||||
)
|
||||
if(_release)
|
||||
string(STRIP "${_release}" _release)
|
||||
set_parent(${_output_release} ${_release})
|
||||
else()
|
||||
set_parent(${_output_release} "NOTFOUND")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(_get_ubuntu_version _output_version)
|
||||
_get_linux_version(_vendor _release)
|
||||
if(_vendor STREQUAL "Ubuntu")
|
||||
string(REGEX MATCH "[0-9]+" _release_major "${_release}")
|
||||
if(_release_major)
|
||||
set_parent(${_output_version} "${_vendor}${_release_major}")
|
||||
return()
|
||||
endif()
|
||||
endif()
|
||||
set_parent(${_output_version} "NOTFOUND")
|
||||
endfunction()
|
||||
|
||||
function(_get_hexagon_sdk_property_impl
|
||||
_hexagon_sdk_root _hexagon_arch _property _output_variable)
|
||||
# Properties
|
||||
# VERSION
|
||||
# SDK_INCLUDE
|
||||
# QURT_INCLUDE
|
||||
# QURT_LIB
|
||||
# RPCMEM_ROOT
|
||||
# DSPRPC_LIB
|
||||
# QAIC_EXE
|
||||
|
||||
if(${ARGC} LESS "4")
|
||||
message(FATAL_ERROR
|
||||
"Invalid number of arguments to get_hexagon_sdk_property"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Set the Hexagon arch directory component.
|
||||
set(_hexarch_dir_v65 "computev65")
|
||||
set(_hexarch_dir_v66 "computev66")
|
||||
set(_hexarch_dir_v68 "computev68")
|
||||
set(_hexarch_dir_v69 "computev69")
|
||||
set(_hexarch_dir_v73 "computev73")
|
||||
set(_hexarch_dir_v75 "computev75")
|
||||
set(_hexarch_dir_str "_hexarch_dir_${_hexagon_arch}")
|
||||
set(_hexarch_dir "${${_hexarch_dir_str}}")
|
||||
|
||||
if(NOT _hexarch_dir)
|
||||
message(SEND_ERROR "Please set Hexagon architecture to one of v65, v66, v68, v69, v73, v75")
|
||||
endif()
|
||||
|
||||
if(_property STREQUAL "VERSION")
|
||||
_check_path_exists("${_hexagon_sdk_root}/incs/version.h" _version_header)
|
||||
if(_version_header)
|
||||
execute_process(
|
||||
COMMAND grep "#define[ \t]*VERSION_STRING" "${_version_header}"
|
||||
OUTPUT_VARIABLE _version_define
|
||||
)
|
||||
string(
|
||||
REGEX REPLACE ".*VERSION_STRING.* ([0-9\\.]+) .*" "\\1"
|
||||
_version_string "${_version_define}"
|
||||
)
|
||||
set_parent(${_output_variable} ${_version_string})
|
||||
else()
|
||||
set_parent(${_output_variable} "${_property}-NOTFOUND")
|
||||
endif()
|
||||
|
||||
elseif(_property STREQUAL "QAIC_EXE")
|
||||
set(_override $ENV{QAIC_PATH_OVERRIDE})
|
||||
if(_override)
|
||||
_check_path_exists("${_override}" _qaic_path)
|
||||
else()
|
||||
_get_ubuntu_version(_uversion)
|
||||
_check_path_exists(
|
||||
"${_hexagon_sdk_root}/ipc/fastrpc/qaic/${_uversion}/qaic"
|
||||
_qaic_path
|
||||
)
|
||||
endif()
|
||||
if(NOT _qaic_path)
|
||||
message(
|
||||
WARNING
|
||||
"The qaic executable cannot be found in '${_qaic_path}'. You can set "
|
||||
"the environment variable QAIC_PATH_OVERRIDE to override the automatic "
|
||||
"search."
|
||||
)
|
||||
endif()
|
||||
set_parent(${_output_variable} "${_qaic_path}")
|
||||
|
||||
else()
|
||||
# The rest of the checks returns path(s), which shares some common code.
|
||||
if(_property STREQUAL "SDK_INCLUDE")
|
||||
set(_dirs "${_hexagon_sdk_root}/incs" "${_hexagon_sdk_root}/incs/stddef")
|
||||
elseif(_property STREQUAL "QURT_INCLUDE")
|
||||
# Set the Hexagon arch directory for runtime linker.
|
||||
set(_rtld_dir "hexagon_toolv84_${_hexagon_arch}")
|
||||
if(_hexagon_arch STREQUAL "v75")
|
||||
set(_rtld_dir "hexagon_toolv87_v75") # Use hexagon_toolv87_v75 for v75
|
||||
endif()
|
||||
if(_hexagon_arch STREQUAL "v69")
|
||||
set(_rtld_dir "hexagon_toolv84_v68") # Use hexagon_toolv84_v68 for v69
|
||||
endif()
|
||||
set(_dirs
|
||||
"${_hexagon_sdk_root}/rtos/qurt/${_hexarch_dir}/include/posix"
|
||||
"${_hexagon_sdk_root}/rtos/qurt/${_hexarch_dir}/include/qurt"
|
||||
"${_hexagon_sdk_root}/ipc/fastrpc/rtld/ship/${_rtld_dir}"
|
||||
)
|
||||
_check_path_exists("${_hexagon_sdk_root}/ipc/fastrpc/rtld/ship/inc" _sdk_dlfcn)
|
||||
if(_sdk_dlfcn)
|
||||
list(APPEND _dirs "${_hexagon_sdk_root}/ipc/fastrpc/rtld/ship/inc")
|
||||
endif()
|
||||
elseif(_property STREQUAL "QURT_LIB")
|
||||
set(_dirs "${_hexagon_sdk_root}/rtos/qurt/${_hexarch_dir}/lib/pic")
|
||||
elseif(_property STREQUAL "RPCMEM_ROOT")
|
||||
set(_dirs "${_hexagon_sdk_root}/ipc/fastrpc/rpcmem")
|
||||
elseif(_property STREQUAL "DSPRPC_LIB")
|
||||
set(_dirs "${_hexagon_sdk_root}/ipc/fastrpc/remote/ship/android_aarch64")
|
||||
else()
|
||||
message(SEND_ERROR "Unknown SDK property ${_property}")
|
||||
endif()
|
||||
|
||||
_check_all_paths_exist("${_dirs}" _dirs_exist)
|
||||
set_parent(${_output_variable} "${_dirs_exist}")
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
function(get_hexagon_sdk_property _hexagon_sdk_root _hexagon_arch)
|
||||
math(EXPR _pnum ${ARGC}-3) # _pnum = number of extra arguments minus 1
|
||||
foreach(_p RANGE 0 ${_pnum} 2) # Range includes the upper bound.
|
||||
list(GET ARGN 0 _property)
|
||||
list(GET ARGN 1 _outvar)
|
||||
_get_hexagon_sdk_property_impl(${_hexagon_sdk_root} ${_hexagon_arch}
|
||||
${_property} _out
|
||||
)
|
||||
set_parent(${_outvar} ${_out})
|
||||
list(REMOVE_AT ARGN 0 1)
|
||||
endforeach()
|
||||
endfunction()
|
||||
@@ -0,0 +1,70 @@
|
||||
# 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.
|
||||
|
||||
# LLVM rules
|
||||
# Due to LLVM debug symbols you can sometimes face linking issues on
|
||||
# certain compiler, platform combinations if you don't set NDEBUG.
|
||||
#
|
||||
# See https://github.com/imageworks/OpenShadingLanguage/issues/1069
|
||||
# for more discussion.
|
||||
add_definitions(-DNDEBUG=1)
|
||||
# TODO(@jroesch, @tkonolige): if we actually use targets we can do this.
|
||||
# target_compile_definitions(tvm_compiler PRIVATE NDEBUG=1)
|
||||
|
||||
# Test if ${USE_LLVM} is not an explicit boolean false
|
||||
# It may be a boolean or a string
|
||||
if(NOT ${USE_LLVM} MATCHES ${IS_FALSE_PATTERN})
|
||||
find_llvm(${USE_LLVM})
|
||||
if (${TVM_LLVM_VERSION} LESS 150)
|
||||
message(FATAL_ERROR "LLVM version 15.0 or greater is required.")
|
||||
endif()
|
||||
include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
|
||||
add_definitions(${LLVM_DEFINITIONS})
|
||||
add_library(tvm_llvm_header INTERFACE)
|
||||
if(MSVC)
|
||||
# MSVC treats GCC-style -isystem operands as source files.
|
||||
target_include_directories(tvm_llvm_header SYSTEM INTERFACE ${LLVM_INCLUDE_DIRS})
|
||||
target_compile_options(tvm_llvm_header INTERFACE ${LLVM_DEFINITIONS})
|
||||
else()
|
||||
set(TVM_LLVM_INCLUDE_FLAGS "")
|
||||
foreach(__llvm_include_dir IN LISTS LLVM_INCLUDE_DIRS)
|
||||
string(STRIP "${__llvm_include_dir}" __llvm_include_dir)
|
||||
list(APPEND TVM_LLVM_INCLUDE_FLAGS "-isystem" "${__llvm_include_dir}")
|
||||
endforeach()
|
||||
target_compile_options(tvm_llvm_header INTERFACE ${TVM_LLVM_INCLUDE_FLAGS} ${LLVM_DEFINITIONS})
|
||||
endif()
|
||||
message(STATUS "Build with LLVM " ${LLVM_PACKAGE_VERSION})
|
||||
message(STATUS "Set TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION})
|
||||
# Set flags that are only needed for LLVM target
|
||||
add_definitions(-DTVM_LLVM_VERSION=${TVM_LLVM_VERSION})
|
||||
if (${TVM_MLIR_VERSION})
|
||||
add_definitions(-DTVM_MLIR_VERSION=${TVM_MLIR_VERSION})
|
||||
endif()
|
||||
add_definitions(-DTVM_LLVM_HAS_AARCH64_TARGET=${TVM_LLVM_HAS_AARCH64_TARGET})
|
||||
tvm_file_glob(GLOB COMPILER_LLVM_SRCS
|
||||
src/target/llvm/*.cc
|
||||
src/backend/cuda/codegen/llvm/*.cc
|
||||
src/backend/rocm/codegen/llvm/*.cc
|
||||
src/backend/hexagon/codegen/llvm/*.cc
|
||||
)
|
||||
list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS})
|
||||
list(APPEND COMPILER_SRCS ${COMPILER_LLVM_SRCS})
|
||||
if(NOT MSVC)
|
||||
set_source_files_properties(${COMPILER_LLVM_SRCS}
|
||||
PROPERTIES COMPILE_FLAGS "-fno-rtti")
|
||||
endif()
|
||||
endif()
|
||||
@@ -0,0 +1,29 @@
|
||||
# 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.
|
||||
|
||||
# This script configures the logging module and dependency on libbacktrace
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(USE_CUSTOM_LOGGING)
|
||||
# Set and propagate TVM_LOG_CUSTOMIZE flag is custom logging has been requested
|
||||
target_compile_definitions(tvm_objs PUBLIC TVM_LOG_CUSTOMIZE=1)
|
||||
target_compile_definitions(tvm_runtime_objs PUBLIC TVM_LOG_CUSTOMIZE=1)
|
||||
target_compile_definitions(tvm_libinfo_objs PUBLIC TVM_LOG_CUSTOMIZE=1)
|
||||
target_compile_definitions(tvm_compiler PUBLIC TVM_LOG_CUSTOMIZE=1)
|
||||
target_compile_definitions(tvm_runtime PUBLIC TVM_LOG_CUSTOMIZE=1)
|
||||
endif()
|
||||
@@ -0,0 +1,37 @@
|
||||
# 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.
|
||||
|
||||
if(USE_METAL)
|
||||
message(STATUS "Build metal device runtime")
|
||||
find_library(METAL_LIB Metal)
|
||||
find_library(FOUNDATION_LIB Foundation)
|
||||
tvm_file_glob(GLOB RUNTIME_METAL_SRCS src/backend/metal/runtime/*.mm)
|
||||
|
||||
add_library(tvm_runtime_metal_objs OBJECT ${RUNTIME_METAL_SRCS})
|
||||
target_link_libraries(tvm_runtime_metal_objs PUBLIC tvm_ffi_header)
|
||||
set_target_properties(tvm_runtime_metal_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(TVM_VISIBILITY_FLAG)
|
||||
target_compile_options(tvm_runtime_metal_objs PRIVATE "${TVM_VISIBILITY_FLAG}")
|
||||
endif()
|
||||
add_library(tvm_runtime_metal SHARED $<TARGET_OBJECTS:tvm_runtime_metal_objs>)
|
||||
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_metal)
|
||||
target_link_libraries(tvm_runtime_metal PUBLIC tvm_runtime ${METAL_LIB} ${FOUNDATION_LIB})
|
||||
tvm_configure_target_library(tvm_runtime_metal RUNTIME_MODULE)
|
||||
endif(USE_METAL)
|
||||
# When USE_METAL=OFF the codegen-side fallback in
|
||||
# src/backend/metal/codegen/metal_fallback_module.cc handles construction; no opt
|
||||
# stub is needed (it is always compiled via CODEGEN_SRCS in CMakeLists.txt).
|
||||
@@ -0,0 +1,65 @@
|
||||
# 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.
|
||||
|
||||
if(USE_OPENCL)
|
||||
tvm_file_glob(GLOB RUNTIME_OPENCL_SRCS src/backend/opencl/runtime/*.cc)
|
||||
|
||||
set(_opencl_libs "")
|
||||
if(${USE_OPENCL} MATCHES ${IS_TRUE_PATTERN})
|
||||
message(STATUS "Enabled runtime search for OpenCL library location")
|
||||
file_glob_append(RUNTIME_OPENCL_SRCS
|
||||
"src/backend/opencl/runtime/opencl_wrapper/opencl_wrapper.cc"
|
||||
)
|
||||
include_directories(SYSTEM "3rdparty/OpenCL-Headers")
|
||||
else()
|
||||
find_opencl(${USE_OPENCL})
|
||||
if(NOT OpenCL_FOUND)
|
||||
message(FATAL_ERROR "Error! Cannot find specified OpenCL library")
|
||||
endif()
|
||||
message(STATUS "Build with OpenCL support")
|
||||
include_directories(SYSTEM ${OpenCL_INCLUDE_DIRS})
|
||||
list(APPEND _opencl_libs ${OpenCL_LIBRARIES})
|
||||
endif()
|
||||
|
||||
message(STATUS "Build opencl device runtime")
|
||||
|
||||
add_library(tvm_runtime_opencl_objs OBJECT ${RUNTIME_OPENCL_SRCS})
|
||||
target_link_libraries(tvm_runtime_opencl_objs PUBLIC tvm_ffi_header)
|
||||
set_target_properties(tvm_runtime_opencl_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(TVM_VISIBILITY_FLAG)
|
||||
target_compile_options(tvm_runtime_opencl_objs PRIVATE "${TVM_VISIBILITY_FLAG}")
|
||||
endif()
|
||||
add_library(tvm_runtime_opencl SHARED $<TARGET_OBJECTS:tvm_runtime_opencl_objs>)
|
||||
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_opencl)
|
||||
target_link_libraries(tvm_runtime_opencl PUBLIC tvm_runtime ${_opencl_libs})
|
||||
tvm_configure_target_library(tvm_runtime_opencl RUNTIME_MODULE)
|
||||
|
||||
if(USE_OPENCL_ENABLE_HOST_PTR)
|
||||
add_definitions(-DOPENCL_ENABLE_HOST_PTR)
|
||||
endif(USE_OPENCL_ENABLE_HOST_PTR)
|
||||
if(USE_OPENCL_EXTN_QCOM)
|
||||
add_definitions(-DUSE_OPENCL_EXTN_QCOM)
|
||||
find_path(ocl_header cl.h HINTS ${OpenCL_INCLUDE_DIRS} PATH_SUFFIXES CL)
|
||||
set(OCL_VERSION_HEADER "${ocl_header}/cl.h")
|
||||
if(EXISTS ${OCL_VERSION_HEADER})
|
||||
file(READ ${OCL_VERSION_HEADER} ver)
|
||||
string(REGEX MATCH "CL_TARGET_OPENCL_VERSION ([0-9]*)" _ ${ver})
|
||||
add_definitions(-DCL_TARGET_OPENCL_VERSION=${CMAKE_MATCH_1})
|
||||
message(STATUS "Set OpenCL Target version to " ${CMAKE_MATCH_1})
|
||||
endif()
|
||||
endif(USE_OPENCL_EXTN_QCOM)
|
||||
endif(USE_OPENCL)
|
||||
@@ -0,0 +1,48 @@
|
||||
# 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.
|
||||
|
||||
# OpenMP Module
|
||||
if(USE_OPENMP STREQUAL "gnu")
|
||||
find_package(OpenMP)
|
||||
if(OPENMP_FOUND)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenMP_CXX_LIBRARIES})
|
||||
add_definitions(-DTVM_THREADPOOL_USE_OPENMP=1)
|
||||
message(STATUS "Build with OpenMP ${OpenMP_CXX_LIBRARIES}")
|
||||
else()
|
||||
add_definitions(-DTVM_THREADPOOL_USE_OPENMP=0)
|
||||
message(WARNING "OpenMP cannot be found, use TVM threadpool instead.")
|
||||
endif()
|
||||
elseif(USE_OPENMP STREQUAL "intel")
|
||||
find_package(OpenMP)
|
||||
if(OPENMP_FOUND)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
|
||||
if (MSVC)
|
||||
find_library(OMP_LIBRARY NAMES libiomp5md)
|
||||
else()
|
||||
find_library(OMP_LIBRARY NAMES iomp5)
|
||||
endif()
|
||||
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OMP_LIBRARY})
|
||||
add_definitions(-DTVM_THREADPOOL_USE_OPENMP=1)
|
||||
message(STATUS "Build with OpenMP " ${OMP_LIBRARY})
|
||||
else()
|
||||
add_definitions(-DTVM_THREADPOOL_USE_OPENMP=0)
|
||||
message(WARNING "OpenMP cannot be found, use TVM threadpool instead.")
|
||||
endif()
|
||||
else()
|
||||
add_definitions(-DTVM_THREADPOOL_USE_OPENMP=0)
|
||||
endif()
|
||||
@@ -0,0 +1,83 @@
|
||||
# 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.
|
||||
|
||||
# ROCM Module
|
||||
find_rocm(${USE_ROCM})
|
||||
|
||||
if(ROCM_FOUND)
|
||||
# always set the includedir
|
||||
# avoid global retrigger of CMake
|
||||
include_directories(SYSTEM ${ROCM_INCLUDE_DIRS})
|
||||
add_definitions(-D__HIP_PLATFORM_HCC__=1)
|
||||
add_definitions(-D__HIP_PLATFORM_AMD__=1)
|
||||
endif(ROCM_FOUND)
|
||||
|
||||
if(USE_ROCM)
|
||||
if(NOT ROCM_FOUND)
|
||||
message(FATAL_ERROR "Cannot find ROCM, USE_ROCM=" ${USE_ROCM})
|
||||
endif()
|
||||
message(STATUS "Build rocm device runtime")
|
||||
|
||||
tvm_file_glob(GLOB RUNTIME_ROCM_SRCS src/backend/rocm/runtime/*.cc)
|
||||
|
||||
set(_rocm_libs ${ROCM_HIPHCC_LIBRARY})
|
||||
if(ROCM_HSA_LIBRARY)
|
||||
list(APPEND _rocm_libs ${ROCM_HSA_LIBRARY})
|
||||
endif()
|
||||
|
||||
add_library(tvm_runtime_rocm_objs OBJECT ${RUNTIME_ROCM_SRCS})
|
||||
target_link_libraries(tvm_runtime_rocm_objs PUBLIC tvm_ffi_header)
|
||||
set_target_properties(tvm_runtime_rocm_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(TVM_VISIBILITY_FLAG)
|
||||
target_compile_options(tvm_runtime_rocm_objs PRIVATE "${TVM_VISIBILITY_FLAG}")
|
||||
endif()
|
||||
add_library(tvm_runtime_rocm SHARED $<TARGET_OBJECTS:tvm_runtime_rocm_objs>)
|
||||
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_rocm)
|
||||
target_link_libraries(tvm_runtime_rocm PUBLIC tvm_runtime ${_rocm_libs})
|
||||
tvm_configure_target_library(tvm_runtime_rocm RUNTIME_MODULE)
|
||||
endif(USE_ROCM)
|
||||
|
||||
# HIPBLAS contrib goes into libtvm_runtime_extra.
|
||||
if(USE_ROCM AND USE_HIPBLAS)
|
||||
message(STATUS "Build with HIPBLAS support")
|
||||
tvm_file_glob(GLOB HIPBLAS_CONTRIB_SRC 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)
|
||||
add_library(tvm_hipblas_objs OBJECT ${HIPBLAS_CONTRIB_SRCS})
|
||||
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(USE_ROCM AND USE_HIPBLAS)
|
||||
|
||||
if(USE_ROCM AND 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$")
|
||||
message(STATUS "Using hipcc compiler to compile rocthrust code.")
|
||||
else()
|
||||
message(FATAL_ERROR "Set CXX=hipcc to compile rocthrust code.")
|
||||
endif()
|
||||
|
||||
find_package(rocprim REQUIRED)
|
||||
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)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_rocthrust_objs roc::rocthrust)
|
||||
endif(USE_ROCM AND USE_THRUST)
|
||||
@@ -0,0 +1,59 @@
|
||||
# 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.
|
||||
|
||||
# Be compatible with older version of CMake
|
||||
find_vulkan(${USE_VULKAN} ${USE_KHRONOS_SPIRV})
|
||||
|
||||
if(USE_VULKAN)
|
||||
if(NOT Vulkan_FOUND)
|
||||
message(FATAL_ERROR "Cannot find Vulkan, USE_VULKAN=" ${USE_VULKAN})
|
||||
endif()
|
||||
if(USE_SPIRV_KHR_INTEGER_DOT_PRODUCT)
|
||||
add_definitions(-DTVM_SPIRV_KHR_INTEGER_DOT_PRODUCT=1)
|
||||
message(STATUS "Enable SPIRV_KHR_INTEGER_DOT_PRODUCT")
|
||||
endif()
|
||||
include_directories(SYSTEM ${Vulkan_INCLUDE_DIRS})
|
||||
message(STATUS "Build with Vulkan support")
|
||||
tvm_file_glob(GLOB COMPILER_VULKAN_SRCS
|
||||
src/backend/vulkan/codegen/build_vulkan.cc
|
||||
src/backend/vulkan/codegen/codegen_spirv.cc
|
||||
src/backend/vulkan/codegen/intrin_rule_spirv.cc
|
||||
src/backend/vulkan/codegen/ir_builder.cc
|
||||
src/backend/vulkan/codegen/spirv_support.cc
|
||||
src/backend/vulkan/codegen/spirv_utils.cc
|
||||
)
|
||||
list(APPEND COMPILER_SRCS ${COMPILER_VULKAN_SRCS})
|
||||
list(APPEND TVM_LINKER_LIBS ${Vulkan_SPIRV_TOOLS_LIBRARY})
|
||||
add_definitions(-DTVM_ENABLE_SPIRV=1)
|
||||
endif(USE_VULKAN)
|
||||
|
||||
if(USE_VULKAN)
|
||||
message(STATUS "Build vulkan device runtime")
|
||||
|
||||
tvm_file_glob(GLOB RUNTIME_VULKAN_SRCS src/backend/vulkan/runtime/*.cc)
|
||||
|
||||
add_library(tvm_runtime_vulkan_objs OBJECT ${RUNTIME_VULKAN_SRCS})
|
||||
target_link_libraries(tvm_runtime_vulkan_objs PUBLIC tvm_ffi_header)
|
||||
set_target_properties(tvm_runtime_vulkan_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
|
||||
if(TVM_VISIBILITY_FLAG)
|
||||
target_compile_options(tvm_runtime_vulkan_objs PRIVATE "${TVM_VISIBILITY_FLAG}")
|
||||
endif()
|
||||
add_library(tvm_runtime_vulkan SHARED $<TARGET_OBJECTS:tvm_runtime_vulkan_objs>)
|
||||
list(APPEND TVM_RUNTIME_BACKEND_LIBS tvm_runtime_vulkan)
|
||||
target_link_libraries(tvm_runtime_vulkan PUBLIC tvm_runtime ${Vulkan_LIBRARY})
|
||||
tvm_configure_target_library(tvm_runtime_vulkan RUNTIME_MODULE)
|
||||
endif(USE_VULKAN)
|
||||
@@ -0,0 +1,23 @@
|
||||
# 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.
|
||||
|
||||
if(USE_AMX)
|
||||
file(GLOB AMX_RUNTIME_CONFIG src/runtime/extra/contrib/amx/amx_config.cc)
|
||||
list(APPEND COMPILER_SRCS ${AMX_RUNTIME_CONFIG})
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=sapphirerapids")
|
||||
message(STATUS "Build with Intel AMX support...")
|
||||
endif()
|
||||
@@ -0,0 +1,74 @@
|
||||
# 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.
|
||||
|
||||
if(USE_BLAS STREQUAL "openblas")
|
||||
find_library(BLAS_LIBRARY openblas)
|
||||
add_library(tvm_blas_objs OBJECT src/runtime/extra/contrib/cblas/cblas.cc)
|
||||
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})
|
||||
endif()
|
||||
elseif(USE_BLAS STREQUAL "atlas" OR USE_BLAS STREQUAL "blas")
|
||||
find_library(BLAS_LIBRARY cblas)
|
||||
add_library(tvm_blas_objs OBJECT src/runtime/extra/contrib/cblas/cblas.cc)
|
||||
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")
|
||||
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_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(DEPRECATION "USE_BLAS=mkl is deprecated. Use USE_MKL=ON instead.")
|
||||
set(USE_MKL ON)
|
||||
elseif(USE_BLAS STREQUAL "none")
|
||||
# pass
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid option: USE_BLAS=" ${USE_BLAS})
|
||||
endif()
|
||||
|
||||
if(USE_MKL OR USE_MKL_PATH)
|
||||
if(USE_MKL_PATH)
|
||||
message(DEPRECATION "USE_MKL_PATH=${USE_MKL_PATH} is deprecated. Use USE_MKL=${USE_MKL_PATH} instead.")
|
||||
endif()
|
||||
if(NOT USE_MKL)
|
||||
set(USE_MKL ${USE_MKL_PATH})
|
||||
endif()
|
||||
if(NOT IS_DIRECTORY ${USE_MKL})
|
||||
set(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)
|
||||
elseif(UNIX)
|
||||
find_library(BLAS_LIBRARY_MKL NAMES mkl_rt mklml_gnu HINTS ${USE_MKL}/lib/ ${USE_MKL}/lib/intel64)
|
||||
elseif(MSVC)
|
||||
find_library(BLAS_LIBRARY_MKL NAMES mkl_rt HINTS ${USE_MKL}/lib/ ${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)
|
||||
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)
|
||||
message(STATUS "Use MKL library " ${BLAS_LIBRARY_MKL})
|
||||
endif()
|
||||
@@ -0,0 +1,90 @@
|
||||
# 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.
|
||||
|
||||
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)
|
||||
include_directories(SYSTEM "3rdparty/OpenCL-Headers")
|
||||
list(APPEND COMPILER_SRCS ${CLML_RELAX_CONTRIB_SRC})
|
||||
if(NOT USE_CLML_GRAPH_EXECUTOR)
|
||||
list(APPEND COMPILER_SRCS ${CLML_RUNTIME_MODULE})
|
||||
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")
|
||||
if(EXISTS ${CLML_VERSION_HEADER})
|
||||
file(READ ${CLML_VERSION_HEADER} ver)
|
||||
string(REGEX MATCH "CL_QCOM_ML_OPS_H_MAJOR_VERSION ([0-9]*)" _ ${ver})
|
||||
set(CLML_VERSION_MAJOR ${CMAKE_MATCH_1})
|
||||
else()
|
||||
set(CLML_VERSION_MAJOR "4")
|
||||
endif()
|
||||
else()
|
||||
set(CLML_VERSION_MAJOR "4")
|
||||
endif()
|
||||
add_definitions(-DTVM_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)
|
||||
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})
|
||||
endif()
|
||||
|
||||
file(GLOB CLML_CONTRIB_SRC 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"
|
||||
)
|
||||
if(NOT EXTERN_CLML_COMPUTE_LIB)
|
||||
string(FIND ${ANDROID_ABI} "64" ARCH_64)
|
||||
set(EXTERN_CLML_COMPUTE_LIB "")
|
||||
if(ARCH_64 GREATER -1)
|
||||
list(APPEND EXTERN_CLML_COMPUTE_LIB ${CLML_PATH}/lib64/libOpenCL.so ${CLML_PATH}/lib64/libOpenCL_system.so)
|
||||
else()
|
||||
list(APPEND EXTERN_CLML_COMPUTE_LIB ${CLML_PATH}/lib/libOpenCL.so ${CLML_PATH}/lib/libOpenCL_system.so)
|
||||
endif()
|
||||
endif()
|
||||
add_library(tvm_clml_objs OBJECT ${CLML_CONTRIB_SRC})
|
||||
target_link_libraries(tvm_clml_objs PRIVATE tvm_runtime_extra_defs)
|
||||
# CLML depends on OpenCL runtime symbols — link the OpenCL DSO instead of
|
||||
# duplicating sources (which would cause duplicate registrations).
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_clml_objs ${EXTERN_CLML_COMPUTE_LIB})
|
||||
if(TARGET tvm_runtime_opencl)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_runtime_opencl)
|
||||
endif()
|
||||
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)
|
||||
|
||||
message(STATUS "Enable OpenCL as fallback to CLML")
|
||||
set(USE_OPENCL ${CLML_PATH})
|
||||
if(USE_OPENCL_ENABLE_HOST_PTR)
|
||||
add_definitions(-DOPENCL_ENABLE_HOST_PTR)
|
||||
endif(USE_OPENCL_ENABLE_HOST_PTR)
|
||||
endif()
|
||||
@@ -0,0 +1,81 @@
|
||||
# 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.
|
||||
|
||||
if(USE_CUDA AND USE_CUTLASS)
|
||||
tvm_file_glob(GLOB CUTLASS_CONTRIB_SRC
|
||||
src/relax/backend/contrib/cutlass/*.cc
|
||||
)
|
||||
list(APPEND COMPILER_SRCS ${CUTLASS_CONTRIB_SRC})
|
||||
|
||||
set(FPA_INTB_GEMM_TVM_BINDING ON)
|
||||
set(FPA_INTB_GEMM_TVM_HOME ${PROJECT_SOURCE_DIR})
|
||||
|
||||
### Build cutlass runtime objects for fpA_intB_gemm using its cutlass submodule
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm)
|
||||
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
|
||||
)
|
||||
target_link_libraries(fpA_intB_gemm_tvm PRIVATE tvm_ffi_header)
|
||||
|
||||
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})
|
||||
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
|
||||
${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm/cutlass/include
|
||||
)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE fpA_intB_cutlass_objs)
|
||||
|
||||
### Build cutlass runtime objects for flash attention
|
||||
add_subdirectory(${PROJECT_SOURCE_DIR}/3rdparty/libflash_attn)
|
||||
target_include_directories(flash_attn PRIVATE
|
||||
${PROJECT_SOURCE_DIR}/3rdparty/libflash_attn
|
||||
${PROJECT_SOURCE_DIR}/3rdparty/libflash_attn/cutlass/include
|
||||
)
|
||||
|
||||
### Build cutlass runtime objects using TVM's 3rdparty/cutlass submodule
|
||||
set(CUTLASS_DIR ${PROJECT_SOURCE_DIR}/3rdparty/cutlass)
|
||||
set(TVM_CUTLASS_RUNTIME_SRCS "")
|
||||
|
||||
if(CMAKE_CUDA_ARCHITECTURES MATCHES "90a")
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp16_group_gemm_sm90.cu)
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp8_group_gemm_sm90.cu)
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp8_gemm.cu)
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp8_groupwise_scaled_gemm_sm90.cu)
|
||||
endif()
|
||||
if(CMAKE_CUDA_ARCHITECTURES MATCHES "100a")
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp16_group_gemm_sm100.cu)
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp8_groupwise_scaled_gemm_sm100.cu)
|
||||
list(APPEND TVM_CUTLASS_RUNTIME_SRCS src/runtime/extra/contrib/cutlass/fp8_groupwise_scaled_group_gemm_sm100.cu)
|
||||
endif()
|
||||
if(TVM_CUTLASS_RUNTIME_SRCS)
|
||||
add_library(tvm_cutlass_objs OBJECT ${TVM_CUTLASS_RUNTIME_SRCS})
|
||||
target_compile_options(tvm_cutlass_objs PRIVATE $<$<COMPILE_LANGUAGE:CUDA>:-lineinfo --expt-relaxed-constexpr>)
|
||||
target_include_directories(tvm_cutlass_objs PRIVATE
|
||||
${CUTLASS_DIR}/include
|
||||
${PROJECT_SOURCE_DIR}/3rdparty/cutlass_fpA_intB_gemm/cutlass_extensions/include
|
||||
)
|
||||
target_link_libraries(tvm_cutlass_objs PRIVATE tvm_runtime_extra_defs)
|
||||
# Note: enable this to get more detailed logs for cutlass kernels
|
||||
# target_compile_definitions(tvm_cutlass_objs PRIVATE CUTLASS_DEBUG_TRACE_LEVEL=2)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_cutlass_objs)
|
||||
endif()
|
||||
|
||||
message(STATUS "Build with CUTLASS")
|
||||
endif()
|
||||
@@ -0,0 +1,26 @@
|
||||
# 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.
|
||||
|
||||
if(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)
|
||||
add_library(tvm_coreml_objs OBJECT ${COREML_CONTRIB_SRC})
|
||||
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)
|
||||
@@ -0,0 +1,63 @@
|
||||
# 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.
|
||||
|
||||
if(IS_DIRECTORY ${USE_DNNL})
|
||||
find_library(EXTERN_LIBRARY_DNNL NAMES dnnl HINTS ${USE_DNNL}/lib/)
|
||||
if(EXTERN_LIBRARY_DNNL STREQUAL "EXTERN_LIBRARY_DNNL-NOTFOUND")
|
||||
message(WARNING "Cannot find DNNL library at ${USE_DNNL}.")
|
||||
else()
|
||||
add_definitions(-DUSE_JSON_RUNTIME=1)
|
||||
tvm_file_glob(GLOB DNNL_CONTRIB_SRC 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
|
||||
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})
|
||||
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)
|
||||
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
|
||||
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})
|
||||
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")
|
||||
find_library(EXTERN_LIBRARY_DNNL dnnl)
|
||||
tvm_file_glob(GLOB DNNL_CONTRIB_SRC 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})
|
||||
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")
|
||||
# pass
|
||||
else()
|
||||
message(FATAL_ERROR "Invalid option: USE_DNNL=" ${USE_DNNL})
|
||||
endif()
|
||||
@@ -0,0 +1,41 @@
|
||||
# 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.
|
||||
|
||||
# Example NPU Codegen
|
||||
if(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)
|
||||
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)
|
||||
list(APPEND COMPILER_SRCS ${RUNTIME_EXAMPLE_NPU_SRCS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Example NPU Runtime — goes into libtvm_runtime_extra.
|
||||
if(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)
|
||||
add_library(tvm_example_npu_objs OBJECT ${RUNTIME_EXAMPLE_NPU_SRCS})
|
||||
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)
|
||||
endif()
|
||||
@@ -0,0 +1,40 @@
|
||||
# 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.
|
||||
|
||||
# NNAPI Codegen
|
||||
if(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)
|
||||
list(APPEND COMPILER_SRCS ${COMPILER_NNAPI_SRCS})
|
||||
if(NOT USE_NNAPI_RUNTIME)
|
||||
list(APPEND COMPILER_SRCS ${RUNTIME_NNAPI_SRCS})
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# NNAPI Runtime — goes into libtvm_runtime_extra.
|
||||
if(USE_NNAPI_RUNTIME)
|
||||
message(STATUS "Build with NNAPI runtime")
|
||||
|
||||
tvm_file_glob(GLOB RUNTIME_NNAPI_SRCS src/runtime/extra/contrib/nnapi/*.cc)
|
||||
add_library(tvm_nnapi_objs OBJECT ${RUNTIME_NNAPI_SRCS})
|
||||
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)
|
||||
endif()
|
||||
@@ -0,0 +1,24 @@
|
||||
# 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.
|
||||
|
||||
if(USE_RANDOM)
|
||||
message(STATUS "Build with contrib.random")
|
||||
tvm_file_glob(GLOB RANDOM_CONTRIB_SRC src/runtime/extra/contrib/random/random.cc)
|
||||
add_library(tvm_random_objs OBJECT ${RANDOM_CONTRIB_SRC})
|
||||
target_link_libraries(tvm_random_objs PRIVATE tvm_runtime_extra_defs)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_random_objs)
|
||||
endif(USE_RANDOM)
|
||||
@@ -0,0 +1,24 @@
|
||||
# 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.
|
||||
|
||||
if(USE_SORT)
|
||||
message(STATUS "Build with contrib.sort")
|
||||
tvm_file_glob(GLOB SORT_CONTRIB_SRC src/runtime/extra/contrib/sort/*.cc)
|
||||
add_library(tvm_sort_objs OBJECT ${SORT_CONTRIB_SRC})
|
||||
target_link_libraries(tvm_sort_objs PRIVATE tvm_runtime_extra_defs)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_sort_objs)
|
||||
endif(USE_SORT)
|
||||
@@ -0,0 +1,59 @@
|
||||
# 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.
|
||||
|
||||
# TensorRT Codegen only. This can be enabled independently of 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.
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
|
||||
if(USE_TENSORRT_CODEGEN)
|
||||
message(STATUS "Build with TensorRT codegen")
|
||||
tvm_file_glob(GLOB COMPILER_TENSORRT_SRCS 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)
|
||||
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)
|
||||
list(APPEND COMPILER_SRCS ${RUNTIME_TENSORRT_SRCS})
|
||||
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})
|
||||
message(STATUS "Custom TensorRT path: " ${TENSORRT_ROOT_DIR})
|
||||
endif()
|
||||
find_path(TENSORRT_INCLUDE_DIR NvInfer.h HINTS ${TENSORRT_ROOT_DIR} PATH_SUFFIXES include)
|
||||
find_library(TENSORRT_LIB_DIR nvinfer HINTS ${TENSORRT_ROOT_DIR} PATH_SUFFIXES lib)
|
||||
find_package_handle_standard_args(TENSORRT DEFAULT_MSG TENSORRT_INCLUDE_DIR TENSORRT_LIB_DIR)
|
||||
if(NOT TENSORRT_FOUND)
|
||||
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)
|
||||
set_source_files_properties(${RUNTIME_TENSORRT_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations")
|
||||
add_library(tvm_tensorrt_objs OBJECT ${RUNTIME_TENSORRT_SRCS})
|
||||
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)
|
||||
endif()
|
||||
@@ -0,0 +1,93 @@
|
||||
# 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.
|
||||
|
||||
# src/arith/z3_prover.cc is always part of COMPILER_SRCS (picked up by the
|
||||
# src/arith/*.cc glob). It compiles a conservative stub by default and switches
|
||||
# to the real Z3 implementation only when the TVM_USE_Z3 macro is defined below.
|
||||
if(${USE_Z3} MATCHES ${IS_FALSE_PATTERN})
|
||||
return()
|
||||
endif()
|
||||
|
||||
set(TVM_Z3_REQUIRED TRUE)
|
||||
if("${USE_Z3}" MATCHES "^[Aa][Uu][Tt][Oo]$")
|
||||
set(TVM_Z3_REQUIRED FALSE)
|
||||
endif()
|
||||
|
||||
# Default lookup: the PIC static Z3 library shipped by the PyPI `z3-static`
|
||||
# package (headers + libz3.a + Z3 CMake package files). Linking it statically
|
||||
# keeps libtvm free of a runtime libz3 dependency. Users can override the
|
||||
# lookup by setting Z3_DIR/CMAKE_PREFIX_PATH to any Z3 installation (e.g. a
|
||||
# shared system Z3).
|
||||
if(NOT Z3_DIR)
|
||||
find_package(Python3 COMPONENTS Interpreter QUIET)
|
||||
if(Python3_EXECUTABLE)
|
||||
execute_process(
|
||||
COMMAND
|
||||
"${Python3_EXECUTABLE}" -m z3_static.config --cmake-dir
|
||||
OUTPUT_VARIABLE Z3_STATIC_CMAKE_DIR
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_QUIET
|
||||
RESULT_VARIABLE Z3_STATIC_RESULT
|
||||
)
|
||||
if(Z3_STATIC_RESULT EQUAL 0 AND EXISTS "${Z3_STATIC_CMAKE_DIR}")
|
||||
set(Z3_DIR "${Z3_STATIC_CMAKE_DIR}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
find_package(Z3 CONFIG QUIET)
|
||||
if(NOT Z3_FOUND AND NOT TARGET z3::libz3 AND NOT TARGET Z3::libz3)
|
||||
find_package(Z3 QUIET)
|
||||
endif()
|
||||
|
||||
if(TARGET z3::libz3 OR TARGET Z3::libz3)
|
||||
if(TARGET z3::libz3)
|
||||
set(Z3_TARGET z3::libz3)
|
||||
else()
|
||||
set(Z3_TARGET Z3::libz3)
|
||||
endif()
|
||||
get_target_property(Z3_TARGET_INCLUDE_DIRS ${Z3_TARGET} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if(Z3_TARGET_INCLUDE_DIRS)
|
||||
include_directories(SYSTEM ${Z3_TARGET_INCLUDE_DIRS})
|
||||
endif()
|
||||
list(APPEND TVM_LINKER_LIBS ${Z3_TARGET})
|
||||
elseif(Z3_FOUND OR (Z3_INCLUDE_DIR AND Z3_LIBRARY))
|
||||
if(NOT Z3_INCLUDE_DIR AND Z3_CXX_INCLUDE_DIRS)
|
||||
set(Z3_INCLUDE_DIR ${Z3_CXX_INCLUDE_DIRS})
|
||||
endif()
|
||||
if(NOT Z3_LIBRARY AND Z3_LIBRARIES)
|
||||
set(Z3_LIBRARY ${Z3_LIBRARIES})
|
||||
endif()
|
||||
if(NOT Z3_INCLUDE_DIR OR NOT Z3_LIBRARY)
|
||||
message(FATAL_ERROR "USE_Z3 is ON, but Z3 include directory or library was not found.")
|
||||
endif()
|
||||
include_directories(SYSTEM ${Z3_INCLUDE_DIR})
|
||||
list(APPEND TVM_LINKER_LIBS ${Z3_LIBRARY})
|
||||
else()
|
||||
if(TVM_Z3_REQUIRED)
|
||||
message(FATAL_ERROR
|
||||
"USE_Z3 is ON, but Z3 was not found. Install the static Z3 development "
|
||||
"package with `pip install 'z3-static>=4.16.0.post1'`, or point "
|
||||
"Z3_DIR/CMAKE_PREFIX_PATH at a Z3 installation.")
|
||||
endif()
|
||||
message(STATUS "Build without Z3 SMT solver support")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Enable the real Z3 implementation inside the single src/arith/z3_prover.cc file.
|
||||
add_compile_definitions(TVM_USE_Z3)
|
||||
message(STATUS "Build with Z3 SMT solver support")
|
||||
@@ -0,0 +1,27 @@
|
||||
# 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.
|
||||
|
||||
if(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)
|
||||
add_library(tvm_vllm_objs OBJECT ${VLLM_CONTRIB_SRC})
|
||||
target_link_libraries(tvm_vllm_objs PRIVATE tvm_runtime_extra_defs)
|
||||
target_link_libraries(tvm_runtime_extra PRIVATE tvm_vllm_objs)
|
||||
endif(USE_VLLM)
|
||||
Reference in New Issue
Block a user