Commit 2d3031ee by Tianqi Chen Committed by GitHub

[BUILD] Switch to CMake only Infra (#1254)

parent cd39697e
......@@ -172,16 +172,19 @@ cscope*
# TVM generated code
perf
.bash_history
*.json
*.params
*.onnx
*.h5
synset.txt
cat.jpg
docs.tgz
cat.png
*.mlmodel
# Mac OS X
.DS_Store
build*
# Jetbrain
.idea
......@@ -4,11 +4,11 @@
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
// tvm libraries
tvm_runtime = "lib/libtvm_runtime.so, config.mk"
tvm_lib = "lib/libtvm.so, " + tvm_runtime
tvm_runtime = "build/libtvm_runtime.so, build/config.cmake"
tvm_lib = "build/libtvm.so, " + tvm_runtime
// LLVM upstream lib
tvm_multilib = "lib/libtvm_llvm40.so, lib/libtvm_llvm50.so, lib/libtvm_llvm60.so, " +
"lib/libtvm_topi.so, nnvm/lib/libnnvm_compiler.so, " + tvm_runtime
tvm_multilib = "build/libtvm.so, " +
"build/libtvm_topi.so, build/libnnvm_compiler.so, " + tvm_runtime
// command to start a docker container
docker_run = 'tests/ci_build/ci_build.sh'
......@@ -48,14 +48,14 @@ stage("Sanity Check") {
// Run make. First try to do an incremental make from a previous workspace in hope to
// accelerate the compilation. If something wrong, clean the workspace and then
// build from scratch.
def make(docker_type, make_flag) {
def make(docker_type, path, make_flag) {
timeout(time: max_time, unit: 'MINUTES') {
try {
sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${make_flag}"
sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${path} ${make_flag}"
} catch (exc) {
echo 'Incremental compilation failed. Fall back to build from scratch'
sh "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh"
sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${make_flag}"
sh "${docker_run} ${docker_type} ./tests/scripts/task_clean.sh ${path}"
sh "${docker_run} ${docker_type} ./tests/scripts/task_build.sh ${path} ${make_flag}"
}
}
}
......@@ -85,33 +85,30 @@ stage('Build') {
ws('workspace/tvm/build-gpu') {
init_git()
sh """
cp make/config.mk .
echo USE_CUDNN=1 >> config.mk
echo USE_CUDA=1 >> config.mk
echo USE_OPENGL=1 >> config.mk
echo LLVM_CONFIG=llvm-config-4.0 >> config.mk
echo USE_RPC=1 >> config.mk
echo USE_SORT=1 >> config.mk
echo USE_GRAPH_RUNTIME=1 >> config.mk
echo USE_BLAS=openblas >> config.mk
rm -f lib/libtvm_runtime.so lib/libtvm.so
mkdir -p build
cd build
cp ../cmake/config.cmake .
echo set\\(USE_CUDNN ON\\) >> config.cmake
echo set\\(USE_CUDA ON\\) >> config.cmake
echo set\\(USE_OPENGL ON\\) >> config.cmake
echo set\\(USE_LLVM llvm-config-6.0\\) >> config.cmake
echo set\\(USE_RPC ON\\) >> config.cmake
echo set\\(USE_SORT ON\\) >> config.cmake
echo set\\(USE_GRAPH_RUNTIME ON\\) >> config.cmake
echo set\\(USE_BLAS openblas\\) >> config.cmake
"""
make('gpu', '-j2')
sh "mv lib/libtvm.so lib/libtvm_llvm40.so"
sh "echo LLVM_CONFIG=llvm-config-5.0 >> config.mk"
make('gpu', '-j2')
sh "mv lib/libtvm.so lib/libtvm_llvm50.so"
sh "echo LLVM_CONFIG=llvm-config-6.0 >> config.mk"
make('gpu', '-j2')
sh "mv lib/libtvm.so lib/libtvm_llvm60.so"
make('gpu', 'build', '-j2')
pack_lib('gpu', tvm_multilib)
// compiler test
sh """
echo USE_OPENCL=1 >> config.mk
echo USE_ROCM=1 >> config.mk
echo ROCM_PATH=/opt/rocm >> config.mk
echo USE_VULKAN=1 >> config.mk
mkdir -p build2
cd build2
cp ../cmake/config.cmake .
echo set\\(USE_OPENCL ON\\) >> config.cmake
echo set\\(USE_ROCM ON\\) >> config.cmake
echo set\\(USE_VULKAN ON\\) >> config.cmake
"""
make('gpu', '-j2')
make('gpu', 'build2', '-j2')
}
}
},
......@@ -120,17 +117,17 @@ stage('Build') {
ws('workspace/tvm/build-cpu') {
init_git()
sh """
cp make/config.mk .
echo USE_CUDA=0 >> config.mk
echo USE_OPENCL=0 >> config.mk
echo USE_RPC=0 >> config.mk
echo USE_SORT=1 >> config.mk
echo USE_OPENGL=1 >> config.mk
echo LLVM_CONFIG=llvm-config-4.0 >> config.mk
echo USE_SORT=1 >> config.mk
mkdir -p build
cd build
cp ../cmake/config.cmake .
echo set\\(USE_SORT ON\\) >> config.cmake
echo set\\(USE_LLVM llvm-config-4.0\\) >> config.cmake
"""
make('cpu', '-j2')
make('cpu', 'build', '-j2')
pack_lib('cpu', tvm_lib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} cpu ./tests/scripts/task_cpp_unittest.sh"
}
}
}
},
......@@ -139,21 +136,14 @@ stage('Build') {
ws('workspace/tvm/build-i386') {
init_git()
sh """
cp make/config.mk .
echo USE_CUDA=0 >> config.mk
echo USE_OPENCL=0 >> config.mk
echo LLVM_CONFIG=llvm-config-4.0 >> config.mk
echo USE_RPC=1 >> config.mk
echo USE_SORT=1 >> config.mk
mkdir -p build
cd build
cp ../cmake/config.cmake .
echo set\\(USE_SORT ON\\) >> config.cmake
echo set\\(USE_RPC ON\\) >> config.cmake
echo set\\(USE_LLVM llvm-config-5.0\\) >> config.cmake
"""
make('i386', '-j2')
sh "mv lib/libtvm.so lib/libtvm_llvm40.so"
sh "echo LLVM_CONFIG=llvm-config-5.0 >> config.mk"
make('i386', '-j2')
sh "mv lib/libtvm.so lib/libtvm_llvm50.so"
sh "echo LLVM_CONFIG=llvm-config-6.0 >> config.mk"
make('i386', '-j2')
sh "mv lib/libtvm.so lib/libtvm_llvm60.so"
make('i386', 'build', '-j2')
pack_lib('i386', tvm_multilib)
}
}
......@@ -166,12 +156,6 @@ stage('Unit Test') {
ws('workspace/tvm/ut-python-gpu') {
init_git()
unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_unittest.sh"
}
// Test on the lastest mainline.
sh "cp lib/libtvm_llvm60.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_unittest.sh"
}
......@@ -183,27 +167,10 @@ stage('Unit Test') {
ws('workspace/tvm/ut-python-i386') {
init_git()
unpack_lib('i386', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} i386 ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} i386 ./tests/scripts/task_python_integration.sh"
}
// Test on llvm 5.0
sh "cp lib/libtvm_llvm50.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} i386 ./tests/scripts/task_python_integration.sh"
}
}
}
},
'cpp': {
node('CPU' && 'linux') {
ws('workspace/tvm/ut-cpp') {
init_git()
unpack_lib('cpu', tvm_lib)
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} cpu ./tests/scripts/task_cpp_unittest.sh"
}
}
}
},
......@@ -212,7 +179,6 @@ stage('Unit Test') {
ws('workspace/tvm/ut-java') {
init_git()
unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_java_unittest.sh"
}
......@@ -227,7 +193,6 @@ stage('Integration Test') {
ws('workspace/tvm/it-python-gpu') {
init_git()
unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_integration.sh"
sh "${docker_run} gpu ./tests/scripts/task_python_topi.sh"
......@@ -242,7 +207,6 @@ stage('Integration Test') {
ws('workspace/tvm/docs-python-gpu') {
init_git()
unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_docs.sh"
}
......
#--------------------------------------------------------------------
# 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 buld in parallel with 8 threads
#
# $ make -j8
#--------------------------------------------------------------------
#---------------------------------------------
# Backend runtimes.
#---------------------------------------------
# whether enable CUDA during compile
set(USE_CUDA OFF)
# ROCM
set(USE_ROCM OFF)
set(ROCM_PATH "/opt/rocm")
# Whether enable OpenCL runtime
set(USE_OPENCL OFF)
# Whether enable Metal runtime
set(USE_METAL OFF)
# Whether enable Vulkan runtime
set(USE_VULKAN OFF)
# Whether enable RPC runtime
set(USE_RPC ON)
# Whether enable tiny embedded graph runtime.
set(USE_GRAPH_RUNTIME ON)
# Whether enable additional graph debug functions
set(USE_GRAPH_RUNTIME_DEBUG OFF)
# Whether build with LLVM support
# Requires LLVM version >= 4.0
#
# Possible values:
# - ON: enable llvm with cmake's find llvm
# - OFF: disbale llvm
# - /path/to/llvm-config enable specific LLVM when multiple llvm-dev is available.
set(USE_LLVM OFF)
#---------------------------------------------
# Contrib libraries
#---------------------------------------------
# Whether use BLAS, choices: openblas, atlas, blas, apple
set(USE_BLAS none)
# Whether use contrib.random in runtime
set(USE_RANDOM OFF)
# Whether use NNPack
set(USE_NNPACK OFF)
# Whether use CuDNN
set(USE_CUDNN OFF)
# Whether use cuBLAS
set(USE_CUBLAS OFF)
# Whether use MIOpen
set(USE_MIOPEN OFF)
# Whether use MPS
set(USE_MPS OFF)
# Whether use rocBlas
set(USE_ROCBLAS OFF)
# Whether use contrib sort
set(USE_SORT OFF)
# CUDA Module
find_package(CUDA QUIET)
if(CUDA_FOUND)
# always set the includedir when cuda is available
# avoid global retrigger of cmake
include_directories(${CUDA_INCLUDE_DIRS})
endif(CUDA_FOUND)
if(USE_CUDA)
find_package(CUDA REQUIRED)
# Find CUDA doesn't find all the libraries we need, add the extra ones
find_library(CUDA_CUDA_LIBRARIES cuda
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs)
find_library(CUDA_NVRTC_LIBRARIES nvrtc
PATHS ${CUDA_TOOLKIT_ROOT_DIR}
PATH_SUFFIXES lib lib64 targets/x86_64-linux/lib targets/x86_64-linux/lib/stubs)
if(CUDA_CUDA_LIBRARIES)
set(CUDA_CUDA_LIBRARY ${CUDA_CUDA_LIBRARIES})
endif()
message(STATUS "Build with CUDA support")
file(GLOB RUNTIME_CUDA_SRCS src/runtime/cuda/*.cc)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDART_LIBRARY})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDA_LIBRARY})
list(APPEND RUNTIME_SRCS ${RUNTIME_CUDA_SRCS})
list(APPEND COMPILER_SRCS src/codegen/opt/build_cuda_on.cc)
if(MSVC)
find_library(CUDA_NVRTC_LIB nvrtc
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
${CUDA_TOOLKIT_ROOT_DIR}/lib/win32)
list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIB})
else(MSVC)
find_library(CUDA_NVRTC_LIB nvrtc
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/lib)
list(APPEND TVM_LINKER_LIBS ${CUDA_NVRTC_LIB})
endif(MSVC)
if(USE_CUDNN)
message(STATUS "Build with cuDNN support")
file(GLOB CONTRIB_CUDNN_SRCS src/contrib/cudnn/*.cc)
list(APPEND RUNTIME_SRCS ${CONTRIB_CUDNN_SRCS})
if(MSVC)
find_library(CUDA_CUDNN_LIB cudnn
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
${CUDA_TOOLKIT_ROOT_DIR}/lib/win32)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIB})
else(MSVC)
find_library(CUDA_CUDNN_LIB cudnn
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/lib)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDNN_LIB})
endif(MSVC)
endif(USE_CUDNN)
if(USE_CUBLAS)
message(STATUS "Build with cuBLAS support")
file(GLOB CONTRIB_CUBLAS_SRCS src/contrib/cublas/*.cc)
list(APPEND RUNTIME_SRCS ${CONTRIB_CUBLAS_SRCS})
if(MSVC)
find_library(CUDA_CUBLAS_LIB cublas
${CUDA_TOOLKIT_ROOT_DIR}/lib/x64
${CUDA_TOOLKIT_ROOT_DIR}/lib/win32)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUBLAS_LIB})
else(MSVC)
find_library(CUDA_CUBLAS_LIB cublas
${CUDA_TOOLKIT_ROOT_DIR}/lib64
${CUDA_TOOLKIT_ROOT_DIR}/lib)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUBLAS_LIB})
endif(MSVC)
endif(USE_CUBLAS)
else(USE_CUDA)
list(APPEND COMPILER_SRCS src/codegen/opt/build_cuda_off.cc)
endif(USE_CUDA)
# LLVM rules
add_definitions(-DDMLC_USE_FOPEN64=0)
if(NOT USE_LLVM STREQUAL "OFF")
if(NOT USE_LLVM STREQUAL "ON")
set(LLVM_CONFIG "${USE_LLVM}")
else()
set(LLVM_CONFIG "")
endif()
find_llvm()
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
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})
file(GLOB COMPILER_LLVM_SRCS src/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_DEFINITIONS "DMLC_ENABLE_RTTI=0")
set_source_files_properties(${COMPILER_LLVM_SRCS}
PROPERTIES COMPILE_FLAGS "-fno-rtti")
endif()
endif()
if(USE_METAL)
message(STATUS "Build with Metal support")
find_library(METAL_LIB Metal)
find_library(FOUNDATION_LIB Foundation)
file(GLOB RUNTIME_METAL_SRCS src/runtime/metal/*.mm)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${METAL_LIB} ${FOUNDATION_LIB})
list(APPEND RUNTIME_SRCS ${RUNTIME_METAL_SRCS})
list(APPEND COMPILER_SRCS src/codegen/opt/build_metal_on.cc)
if(USE_MPS)
file(GLOB MPS_CONTRIB_SRC src/contrib/mps/*.mm)
list(APPEND RUNTIME_SRCS ${MPS_CONTRIB_SRC})
find_library(MPS_CONTRIB_LIB MetalPerformanceShaders)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${MPS_CONTRIB_LIB})
endif()
else(USE_METAL)
list(APPEND COMPILER_SRCS src/codegen/opt/build_metal_off.cc)
endif(USE_METAL)
# OPENCL Module
find_package(OpenCL QUIET)
if(OpenCL_FOUND)
# always set the includedir when cuda is available
# avoid global retrigger of cmake
include_directories(${OpenCL_INCLUDE_DIRS})
endif(OpenCL_FOUND)
if(USE_OPENCL)
find_package(OpenCL REQUIRED)
message(STATUS "Build with OpenCL support")
file(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES})
list(APPEND RUNTIME_SRCS ${RUNTIME_OPENCL_SRCS})
list(APPEND COMPILER_SRCS src/codegen/opt/build_opencl_on.cc)
else()
list(APPEND COMPILER_SRCS src/codegen/opt/build_opencl_off.cc)
endif(USE_OPENCL)
find_package(OpenGL QUIET)
if(OpenGL_FOUND)
# always set the includedir when dir is available
# avoid global retrigger of cmake
include_directories(${OPENGL_INCLUDE_DIRS})
endif(OpenGL_FOUND)
if(USE_OPENGL)
find_package(OpenGL REQUIRED)
find_package(glfw3 QUIET REQUIRED)
message(STATUS "Build with OpenGL support")
file(GLOB RUNTIME_OPENGL_SRCS src/runtime/opengl/*.cc)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenGL_LIBRARIES} glfw)
list(APPEND RUNTIME_SRCS ${RUNTIME_OPENGL_SRCS})
list(APPEND COMPILER_SRCS src/codegen/opt/build_opengl_on.cc)
else(USE_OPENGL)
list(APPEND COMPILER_SRCS src/codegen/opt/build_opengl_off.cc)
endif(USE_OPENGL)
# ROCM Module
if(NOT ROCM_PATH STREQUAL "")
include_directories(${ROCM_PATH}/include)
set(ROCM_LIB_PATH ${ROCM_PATH}/lib)
else()
set(ROCM_LIB_PATH /lib)
endif()
if(USE_ROCM)
message(STATUS "Build with ROCM support")
find_library(ROCM_LIBS hip_hcc ${ROCM_LIB_PATH})
file(GLOB RUNTIME_ROCM_SRCS src/runtime/rocm/*.cc)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${ROCM_LIBS})
list(APPEND RUNTIME_SRCS ${RUNTIME_ROCM_SRCS})
add_definitions(-DTVM_ROCM_RUNTIME=1 -D__HIP_PLATFORM_HCC__=1)
if(USE_MIOPEN)
message(STATUS "Build with MIOpen support")
file(GLOB MIOPEN_CONTRIB_SRCS src/contrib/miopen/*.cc)
list(APPEND RUNTIME_SRCS ${MIOPEN_CONTRIB_SRCS})
find_library(MIOPEN_LIBS MIOpen ${ROCM_LIB_PATH})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${MIOPEN_LIBS})
endif(USE_MIOPEN)
if(USE_ROCBLAS)
message(STATUS "Build with RocBLAS support")
file(GLOB ROCBLAS_CONTRIB_SRCS src/contrib/rocblas/*.cc)
list(APPEND RUNTIME_SRCS ${ROCBLAS_CONTRIB_SRCS})
find_library(ROCBLAS_LIBS rocblas ${ROCM_LIB_PATH})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${ROCBLAS_LIBS})
endif(USE_ROCBLAS)
else(USE_ROCM)
add_definitions(-DTVM_ROCM_RUNTIME=0)
endif(USE_ROCM)
# Be compatible with older version of CMake
if(NOT $ENV{VULKAN_SDK} STREQUAL "")
set(Vulkan_INCLUDE_DIRS $ENV{VULKAN_SDK}/include)
set(Vulkan_FOUND ON)
else()
find_package(Vulkan QUIET)
endif()
if(Vulkan_FOUND)
# always set the includedir when cuda is available
# avoid global retrigger of cmake
include_directories(${Vulkan_INCLUDE_DIRS})
endif(Vulkan_FOUND)
if(USE_VULKAN)
if(NOT $ENV{VULKAN_SDK} STREQUAL "")
find_library(Vulkan_LIBRARY vulkan $ENV{VULKAN_SDK}/lib)
else()
find_package(Vulkan REQUIRED)
endif()
message(STATUS "Build with VULKAN support")
file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/*.cc)
file(GLOB COMPILER_VULKAN_SRCS src/codegen/spirv/*.cc)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${Vulkan_LIBRARY})
list(APPEND RUNTIME_SRCS ${RUNTIME_VULKAN_SRCS})
list(APPEND COMPILER_SRCS ${COMPILER_VULKAN_SRCS})
get_filename_component(VULKAN_LIB_PATH ${Vulkan_LIBRARY} DIRECTORY)
find_library(SPIRV_TOOLS_LIB SPIRV-Tools
${VULKAN_LIB_PATH}/spirv-tools)
list(APPEND TVM_LINKER_LIBS ${SPIRV_TOOLS_LIB})
endif(USE_VULKAN)
# Plugin rules for cblas
file(GLOB CBLAS_CONTRIB_SRC src/contrib/cblas/*.cc)
if(USE_BLAS STREQUAL "openblas")
find_library(BLAS_LIBRARY openblas)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${BLAS_LIBRARY})
list(APPEND RUNTIME_SRCS ${CBLAS_CONTRIB_SRC})
message(STATUS "Use BLAS library " ${BLAS_LIBRARY})
elseif(USE_BLAS STREQUAL "atlas" OR USE_BLAS STREQUAL "blas")
find_library(BLAS_LIBRARY cblas)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${BLAS_LIBRARY})
list(APPEND RUNTIME_SRCS ${CBLAS_CONTRIB_SRC})
message(STATUS "Use BLAS library " ${BLAS_LIBRARY})
elseif(USE_BLAS STREQUAL "apple")
find_library(BLAS_LIBRARY Accelerate)
include_directories(${BLAS_LIBRARY}/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${BLAS_LIBRARY})
list(APPEND RUNTIME_SRCS ${CBLAS_CONTRIB_SRC})
message(STATUS "Use BLAS library " ${BLAS_LIBRARY})
elseif(USE_BLAS STREQUAL "none")
# pass
else()
message(FATAL_ERROR "Invalid option: USE_BLAS=" ${USE_BLAS})
endif()
if(USE_NNPACK)
if(NNPACK_PATH STREQUAL "")
set(NNPACK_PATH ${CMAKE_CURRENT_SOURCE_DIR}/NNPack)
endif()
set(PTHREAD_POOL_PATH ${NNPACK_PATH}/deps/pthreadpool)
file(GLOB NNPACK_CONTRIB_SRC src/contrib/nnpack/*.cc)
list(APPEND RUNTIME_SRCS ${NNPACK_CONTRIB_SRC})
include_directories(${NNPACK_PATH}/include)
include_directories(${PTHREAD_POOL_PATH}/include)
find_library(NNPACK_CONTRB_LIB nnpack ${NNPACK_PATH}/lib)
find_library(NNPACK_PTHREAD_CONTRIB_LIB pthreadpool ${NNPACK_PATH}/lib)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${NNPACK_CONTRIB_LIB})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${NNPACK_PTHREAD_CONTRIB_LIB})
endif(USE_NNPACK)
if(USE_RANDOM)
message(STATUS "Build with contrib.random")
file(GLOB RANDOM_CONTRIB_SRC src/contrib/random/random.cc)
list(APPEND RUNTIME_SRCS ${RANDOM_CONTRIB_SRC})
endif(USE_RANDOM)
if(USE_SORT)
message(STATUS "Build with contrib.sort")
file(GLOB SORT_CONTRIB_SRC src/contrib/sort/*.cc)
list(APPEND RUNTIME_SRCS ${SORT_CONTRIB_SRC})
endif(USE_SORT)
#######################################################
# Enhanced version of find llvm that allows set of LLVM_CONFIG
# When LLVM_CONFIG_PATH is AUTO,
# it defaults to system find llvm
#
# Usage:
# find_llvm(LLVM_CONFIG_PATH)
#
# Provide variables:
# - LLVM_INCLUDE_DIRS
# - LLVM_LIBS
# - LLVM_DEFINITIONS
# - LLVM_VERSION_CONCAT
#
macro(find_llvm)
if(LLVM_CONFIG STREQUAL "")
find_package(LLVM REQUIRED CONFIG)
llvm_map_components_to_libnames(LLVM_LIBS all)
list(REMOVE_ITEM LLVM_LIBS LTO)
set(TVM_LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})
else()
# use llvm config
message(STATUS "Use llvm-config=" ${LLVM_CONFIG})
execute_process(COMMAND ${LLVM_CONFIG} --includedir
OUTPUT_VARIABLE LLVM_INCLUDE_DIRS)
execute_process(COMMAND ${LLVM_CONFIG} --libfiles
OUTPUT_VARIABLE LLVM_LIBS)
execute_process(COMMAND ${LLVM_CONFIG} --cxxflags
OUTPUT_VARIABLE __llvm_cxxflags)
execute_process(COMMAND ${LLVM_CONFIG} --version
COMMAND cut -b 1,3
OUTPUT_VARIABLE TVM_LLVM_VERSION)
string(REGEX MATCHALL "(^| )-D[A-Za-z0-9_]*" LLVM_DEFINITIONS ${__llvm_cxxflags})
string(STRIP ${LLVM_LIBS} LLVM_LIBS)
separate_arguments(LLVM_LIBS)
string(STRIP ${LLVM_INCLUDE_DIRS} LLVM_INCLUDE_DIRS)
string(STRIP ${TVM_LLVM_VERSION} TVM_LLVM_VERSION)
endif()
endmacro(find_llvm)
macro(__tvm_option variable description value)
if(NOT DEFINED ${variable})
set(${variable} ${value} CACHE STRING ${description})
endif()
endmacro()
#######################################################
# 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>])
function(tvm_option variable description value)
macro(tvm_option variable description value)
set(__value ${value})
set(__condition "")
set(__varname "__value")
......@@ -21,23 +27,23 @@ function(tvm_option variable description value)
if(${__condition})
if("${__value}" MATCHES ";")
if(${__value})
option(${variable} "${description}" ON)
__tvm_option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
__tvm_option(${variable} "${description}" OFF)
endif()
elseif(DEFINED ${__value})
if(${__value})
option(${variable} "${description}" ON)
__tvm_option(${variable} "${description}" ON)
else()
option(${variable} "${description}" OFF)
__tvm_option(${variable} "${description}" OFF)
endif()
else()
option(${variable} "${description}" ${__value})
__tvm_option(${variable} "${description}" "${__value}")
endif()
else()
unset(${variable} CACHE)
endif()
endfunction()
endmacro()
function(assign_source_group group)
foreach(_source IN ITEMS ${ARGN})
......
......@@ -38,13 +38,23 @@ Our goal is to build the shared libraries:
The minimal building requirements are
- A recent c++ compiler supporting C++ 11 (g++-4.8 or higher)
- CMake 3.7 or higher
- We highly recommend to build with LLVM to enable all the features.
- It is possible to build without llvm dependency if we only want to use CUDA/OpenCL
The configuration of tvm can be modified by `config.mk`
We use cmake to build the library.
The configuration of tvm can be modified by `config.cmake`.
- First copy ``make/config.mk`` to the project root, on which
any local modification will be ignored by git, then modify the according flags.
- First, check the cmake in your system, you do not have cmake
you can obtain the latest version from `official website <https://cmake.org/download/>`_
- First create a build directory, copy the ``cmake/config.cmake`` to the directory.
.. code:: bash
mkdir build
cp cmake/config.cmake build
- Edit ``build/config.cmake`` to customize the compilation options
- On macOS, for some versions of XCode, you need to add ``-lc++abi`` in the LDFLAGS or you'll get link errors.
......@@ -54,27 +64,22 @@ The configuration of tvm can be modified by `config.mk`
- Since LLVM takes long time to build from source, you can download pre-built version of LLVM from
[LLVM Download Page](http://releases.llvm.org/download.html).
- Unzip to a certain location, modify ``config.mk`` to add ``LLVM_CONFIG=/path/to/your/llvm/bin/llvm-config``
- Unzip to a certain location, modify ``build/config.cmake`` to add ``set(USE_LLVM /path/to/your/llvm/bin/llvm-config)``
- You can also directly set ``set(USE_LLVM ON)`` and let cmake search for a usable version of LLVM.
- You can also use [LLVM Nightly Ubuntu Build](https://apt.llvm.org/)
- Note that apt-package append ``llvm-config`` with version number.
For example, set ``LLVM_CONFIG=llvm-config-4.0`` if you installed 4.0 package
For example, set ``set(LLVM_CONFIG llvm-config-4.0)`` if you installed 4.0 package
We can then build tvm by `make`.
.. code:: bash
- We can then build tvm and related libraries.
.. code:: bash
cd build
cmake ..
make -j4
After we build tvm, we can proceed to build nnvm using the following command.
.. code:: bash
make nnvm -j4
This will creates `libnnvm_compiler.so` under the `nnvm/lib` folder.
If everything goes well, we can go to the specific language installation section.
......@@ -101,7 +106,7 @@ Building ROCm support
Currently, ROCm is supported only on linux, so all the instructions are written with linux in mind.
- Set ``USE_ROCM=1``, set ROCM_PATH to the correct path.
- Set ``set(USE_ROCM ON)``, set ROCM_PATH to the correct path.
- You need to first install HIP runtime from ROCm. Make sure the installation system has ROCm installed in it.
- Install latest stable version of LLVM (v6.0.1), and LLD, make sure ``ld.lld`` is available via command line.
......
......@@ -71,9 +71,8 @@ sudo ldconfig
git clone --recursive https://github.com/dmlc/tvm
```
* Set `USE_NNPACK = 1` in config.mk.
* Set `set(USE_NNPACK ON)` in config.cmake.
* Set `NNPACK_PATH` to the $(YOUR_NNPACK_INSTALL_PATH)
* Set `LLVM_CONFIG = llvm-config-4.0` depending of llvm version installed
after configuration use `make` to build TVM
......
/*!
* Copyright (c) 2017 by Contributors
* \file tvm/runtime/config.h
* \brief Runtime library related configurations.
*/
#ifndef TVM_RUNTIME_CONFIG_H_
#define TVM_RUNTIME_CONFIG_H_
/*!
*\brief whether to use CUDA runtime
*/
#ifndef TVM_CUDA_RUNTIME
#define TVM_CUDA_RUNTIME 1
#endif
/*!
*\brief whether to use opencl runtime
*/
#ifndef TVM_OPENCL_RUNTIME
#define TVM_OPENCL_RUNTIME 0
#endif
/*!
*\brief whether to use metal runtime
*/
#ifndef TVM_METAL_RUNTIME
#define TVM_METAL_RUNTIME 0
#endif
#endif // TVM_RUNTIME_CONFIG_H_
......@@ -6,7 +6,7 @@
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>../../../lib/libtvm_runtime.so</source>
<source>../../../build/libtvm_runtime.so</source>
<outputDirectory>lib/native</outputDirectory>
<fileMode>0644</fileMode>
</file>
......
......@@ -6,7 +6,7 @@
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>../../../lib/libtvm_runtime.so</source>
<source>../../../build/libtvm_runtime.so</source>
<outputDirectory>lib/native</outputDirectory>
<fileMode>0644</fileMode>
</file>
......
......@@ -6,7 +6,7 @@
<includeBaseDirectory>false</includeBaseDirectory>
<files>
<file>
<source>../../../lib/libtvm_runtime.dylib</source>
<source>../../../build/libtvm_runtime.dylib</source>
<outputDirectory>lib/native</outputDirectory>
<fileMode>0644</fileMode>
</file>
......
......@@ -91,7 +91,7 @@
<threadCount>1</threadCount>
<argLine>
-Djava.library.path=${project.parent.basedir}/native/${platform}/target
-Dlibtvm.so.path=${project.parent.basedir}/../lib/${libtvm.so.filename}
-Dlibtvm.so.path=${project.parent.basedir}/../build/${libtvm.so.filename}
</argLine>
</configuration>
<executions>
......
#-------------------------------------------------------------------------------
# Template configuration for compiling
#
# 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
#
# $ cp make/config.mk .
#
# Next modify the according entries, and then compile by
#
# $ make
#
# or build in parallel with 8 threads
#
# $ make -j8
#-------------------------------------------------------------------------------
# whether compile with debug
DEBUG = 0
# the additional link flags you want to add
ADD_LDFLAGS =
# the additional compile flags you want to add
ADD_CFLAGS =
#---------------------------------------------
# Backend runtimes.
#---------------------------------------------
# whether enable CUDA during compile
USE_CUDA = 0
# add the path to CUDA library to link and compile flag
# if you have already add them to environment variable.
# CUDA_PATH = /usr/local/cuda
# ROCM
USE_ROCM = 0
# whether enable OpenCL during compile
USE_OPENCL = 0
# whether enable Metal during compile
USE_METAL = 0
# whether enable SGX during compile
USE_SGX = 0
SGX_SDK = /opt/sgxsdk
# Whether enable RPC during compile
USE_RPC = 1
# Whether enable tiny embedded graph runtime.
USE_GRAPH_RUNTIME = 1
# Whether enable additional graph debug functions
USE_GRAPH_RUNTIME_DEBUG = 0
# whether build with LLVM support
# Requires LLVM version >= 4.0
# Set LLVM_CONFIG to your version, uncomment to build with llvm support
#
# LLVM_CONFIG = llvm-config
#---------------------------------------------
# Contrib optional libraries.
#---------------------------------------------
# Whether use BLAS, choices: openblas, atlas, blas, apple
USE_BLAS = none
# Whether use contrib.random in runtime
USE_RANDOM = 0
# Whether use NNPack
USE_NNPACK = 0
# NNPACK_PATH = none
# Whether use CuDNN
USE_CUDNN = 0
# Whether use MIOpen
USE_MIOPEN = 0
# Whether use MPS
USE_MPS = 0
# Whether use cuBLAS
USE_CUBLAS = 0
# Whether use rocBlas
USE_ROCBLAS = 0
# Whether use contrib sort
USE_SORT = 0
CBLAS_CONTRIB_SRC = $(wildcard src/contrib/cblas/*.cc)
CBLAS_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(CBLAS_CONTRIB_SRC))
ifeq ($(USE_BLAS), openblas)
ADD_LDFLAGS += -lopenblas
RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ)
else ifeq ($(USE_BLAS), atlas)
ADD_LDFLAGS += -lcblas
RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ)
else ifeq ($(USE_BLAS), blas)
ADD_LDFLAGS += -lblas
RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ)
else ifeq ($(USE_BLAS), apple)
ADD_CFLAGS += -I/System/Library/Frameworks/Accelerate.framework/Versions/Current/Frameworks/vecLib.framework/Versions/Current/Headers/
FRAMEWORKS += -framework Accelerate
RUNTIME_DEP += $(CBLAS_CONTRIB_OBJ)
endif
CUBLAS_CONTRIB_SRC = $(wildcard src/contrib/cublas/*.cc)
CUBLAS_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(CUBLAS_CONTRIB_SRC))
ifeq ($(USE_CUBLAS), 1)
CFLAGS += -DTVM_USE_CUBLAS=1
ADD_LDFLAGS += -lcublas
RUNTIME_DEP += $(CUBLAS_CONTRIB_OBJ)
endif
CUDNN_CONTRIB_SRC = $(wildcard src/contrib/cudnn/*.cc)
CUDNN_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(CUDNN_CONTRIB_SRC))
ifeq ($(USE_CUDNN), 1)
CFLAGS += -DTVM_USE_CUDNN=1 -I$(CUDA_PATH)/include
ADD_LDFLAGS += -lcudnn
RUNTIME_DEP += $(CUDNN_CONTRIB_OBJ)
endif
MIOPEN_CONTRIB_SRC = $(wildcard src/contrib/miopen/*.cc)
MIOPEN_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(MIOPEN_CONTRIB_SRC))
ifeq ($(USE_MIOPEN), 1)
CFLAGS += -DTVM_USE_MIOPEN=1
ADD_LDFLAGS += -lMIOpen
RUNTIME_DEP += $(MIOPEN_CONTRIB_OBJ)
endif
MPS_CONTRIB_SRC = $(wildcard src/contrib/mps/*.mm)
MPS_CONTRIB_OBJ = $(patsubst src/%.mm, build/%.o, $(MPS_CONTRIB_SRC))
ifeq ($(USE_MPS), 1)
FRAMEWORKS += -framework MetalPerformanceShaders
CFLAGS +=
ADD_LDFLAGS +=
RUNTIME_DEP += $(MPS_CONTRIB_OBJ)
CONTRIB_OBJ += $(MPS_CONTRIB_OBJ)
endif
build/contrib/mps/%.o: src/contrib/mps/%.mm
@mkdir -p $(@D)
$(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/contrib/mps/$*.o $< >build/contrib/mps/$*.d
$(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@
build/contrib/mps/%.o: src/contrib/mps/%.cc
@mkdir -p $(@D)
$(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/contrib/mps/$*.o $< >build/contrib/mps/$*.d
$(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@
NNPACK_CONTRIB_SRC = $(wildcard src/contrib/nnpack/*.cc)
NNPACK_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(NNPACK_CONTRIB_SRC))
ifeq ($(USE_NNPACK), 1)
ifndef NNPACK_PATH
NNPACK_PATH = $(ROOTDIR)/NNPACK
endif
PTHREAD_POOL_PATH = $(NNPACK_PATH)/deps/pthreadpool
CFLAGS += -DTVM_USE_NNPACK=1 -I$(NNPACK_PATH)/include -I$(PTHREAD_POOL_PATH)/include
LDFLAGS += -L$(NNPACK_PATH)/lib -lnnpack -lpthreadpool -lpthread
RUNTIME_DEP += $(NNPACK_CONTRIB_OBJ)
endif
RANDOM_CONTRIB_SRC = $(wildcard src/contrib/random/random.cc)
RANDOM_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(RANDOM_CONTRIB_SRC))
ifeq ($(USE_RANDOM), 1)
RUNTIME_DEP += $(RANDOM_CONTRIB_OBJ)
endif
ROCBLAS_CONTRIB_SRC = $(wildcard src/contrib/rocblas/*.cc)
ROCBLAS_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(ROCBLAS_CONTRIB_SRC))
ifeq ($(USE_ROCBLAS), 1)
CFLAGS += -DTVM_USE_ROCBLAS=1
ADD_LDFLAGS += -lrocblas
RUNTIME_DEP += $(ROCBLAS_CONTRIB_OBJ)
endif
SORT_CONTRIB_SRC = $(wildcard src/contrib/sort/*.cc)
SORT_CONTRIB_OBJ = $(patsubst src/%.cc, build/%.o, $(SORT_CONTRIB_SRC))
ifeq ($(USE_SORT), 1)
RUNTIME_DEP += $(SORT_CONTRIB_OBJ)
endif
......@@ -3,7 +3,6 @@
* \file codegen_cuda.cc
*/
#include <tvm/base.h>
#include <tvm/runtime/config.h>
#include <tvm/runtime/registry.h>
#include <tvm/packed_func_ext.h>
#include <vector>
......
......@@ -2,7 +2,6 @@
* Copyright (c) 2017 by Contributors
* \file codegen_metal.cc
*/
#include <tvm/runtime/config.h>
#include <tvm/packed_func_ext.h>
#include <vector>
#include <string>
......
......@@ -2,7 +2,6 @@
* Copyright (c) 2017 by Contributors
* \file codegen_opencl.cc
*/
#include <tvm/runtime/config.h>
#include <tvm/packed_func_ext.h>
#include <vector>
#include <string>
......
......@@ -5,7 +5,6 @@
* We are targeting OpenGL 3.3. The reason of not targeting a recent version
* of OpenGL is to have better compatibility of WebGL 2.
*/
#include <tvm/runtime/config.h>
#include <tvm/packed_func_ext.h>
#include <vector>
#include <string>
......
......@@ -105,7 +105,6 @@ class CodeGenAMDGPU : public CodeGenLLVM {
llvm::Value* CreateStorageSync(const Call* op) final {
const std::string& sync = op->args[0].as<StringImm>()->value;
if (sync == "warp") {
// TODO(tqchen) warp sync in CUDA9
return nullptr;
} else if (sync == "shared") {
llvm::Function* f = llvm::Intrinsic::getDeclaration(
......
......@@ -4,7 +4,6 @@
* \brief NVPTX code generator.
*/
#ifdef TVM_LLVM_VERSION
#if TVM_CUDA_RUNTIME
#include <tvm/runtime/device_api.h>
#include "./codegen_llvm.h"
......@@ -215,5 +214,4 @@ TVM_REGISTER_API("codegen.build_nvptx")
} // namespace codegen
} // namespace tvm
#endif // TVM_CUDA_RUNTIME
#endif // TVM_LLVM_VERSION
This folder contains optional builds for codegen depending on compilation options.
/*!
* Copyright (c) 2018 by Contributors
* Optional module when build cuda is switched to off
*/
#include "../../runtime/cuda/cuda_module.h"
namespace tvm {
namespace runtime {
Module CUDAModuleCreate(
std::string data,
std::string fmt,
std::unordered_map<std::string, FunctionInfo> fmap,
std::string cuda_source) {
LOG(FATAL) << "CUDA is not enabled";
return Module();
}
} // namespace runtime
} // namespace tvm
/*!
* Copyright (c) 2017 by Contributors
* Build cuda modules from source.
* requires cuda to be available.
*
* \file build_cuda.cc
*/
#include <tvm/base.h>
#include <tvm/runtime/config.h>
#include "./codegen_cuda.h"
#include "./build_common.h"
#if TVM_CUDA_RUNTIME
#include <nvrtc.h>
#include "../runtime/cuda/cuda_common.h"
#include "../runtime/cuda/cuda_module.h"
#include "../codegen_cuda.h"
#include "../build_common.h"
#include "../../runtime/cuda/cuda_common.h"
#include "../../runtime/cuda/cuda_module.h"
namespace tvm {
namespace codegen {
......@@ -79,4 +79,3 @@ TVM_REGISTER_API("codegen.build_cuda")
});
} // namespace codegen
} // namespace tvm
#endif // TVM_CUDA_RUNTIME
/*!
* Copyright (c) 2017 by Contributors
* Build metal modules from source.
* \file build_metal.cc
* \file build_metal.h
*/
#include <tvm/base.h>
#include <tvm/runtime/config.h>
#include "./codegen_metal.h"
#include "./build_common.h"
#ifndef TVM_CODEGEN_OPT_BUILD_METAL_H_
#define TVM_CODEGEN_OPT_BUILD_METAL_H_
#include <string>
#include "../codegen_metal.h"
#include "../build_common.h"
#if TVM_METAL_RUNTIME
#include "../runtime/metal/metal_module.h"
#include "../../runtime/metal/metal_module.h"
#endif // TVM_METAL_RUNTIME
namespace tvm {
......@@ -45,3 +47,4 @@ TVM_REGISTER_API("codegen.build_metal")
});
} // namespace codegen
} // namespace tvm
#endif // TVM_CODEGEN_OPT_BUILD_METAL_H_
/*!
* Copyright (c) 2018 by Contributors
* Build Metal modules off
*/
#define TVM_METAL_RUNTIME 0
#include "./build_metal.h"
/*!
* Copyright (c) 2018 by Contributors
* Build Metal modules on
*/
#define TVM_METAL_RUNTIME 1
#include "./build_metal.h"
/*!
* Copyright (c) 2017 by Contributors
* Build opencl modules from source.
* \file build_opencl.cc
* \file build_opencl.h
*/
#ifndef TVM_CODEGEN_OPT_BUILD_OPENCL_H_
#define TVM_CODEGEN_OPT_BUILD_OPENCL_H_
#include <tvm/base.h>
#include <tvm/runtime/config.h>
#include "./codegen_opencl.h"
#include "./build_common.h"
#include <string>
#include "../codegen_opencl.h"
#include "../build_common.h"
#if TVM_OPENCL_RUNTIME
#include "../runtime/opencl/opencl_module.h"
#include "../../runtime/opencl/opencl_module.h"
#endif // TVM_OPENCL_RUNTIME
namespace tvm {
......@@ -42,3 +45,4 @@ TVM_REGISTER_API("codegen.build_opencl")
});
} // namespace codegen
} // namespace tvm
#endif // TVM_CODEGEN_OPT_BUILD_OPENCL_H_
/*!
* Copyright (c) 2018 by Contributors
* Build opencl modules off
*/
#define TVM_OPENCL_RUNTIME 0
#include "./build_opencl.h"
/*!
* Copyright (c) 2018 by Contributors
* Build opencl modules on
*/
#define TVM_OPENCL_RUNTIME 1
#include "./build_opencl.h"
/*!
* Copyright (c) 2017 by Contributors
* Build opengl modules from source.
* \file build_opengl.cc
* \file build_opengl.h
*/
#ifndef TVM_CODEGEN_OPT_BUILD_OPENGL_H_
#define TVM_CODEGEN_OPT_BUILD_OPENGL_H_
#include <tvm/base.h>
#include "./codegen_opengl.h"
#include "./build_common.h"
#include "../codegen_opengl.h"
#include "../build_common.h"
namespace tvm {
namespace codegen {
......@@ -33,3 +36,4 @@ TVM_REGISTER_API("codegen.build_opengl")
});
} // namespace codegen
} // namespace tvm
#endif // TVM_CODEGEN_OPT_BUILD_OPENGL_H_
/*!
* Copyright (c) 2018 by Contributors
* Build OpenGL modules off
*/
#define TVM_OPENGL_RUNTIME 0
#include "./build_opengl.h"
/*!
* Copyright (c) 2018 by Contributors
* Build OpenGL modules on
*/
#define TVM_OPENGL_RUNTIME 1
#include "./build_opengl.h"
......@@ -6,12 +6,9 @@
#ifndef TVM_RUNTIME_CUDA_CUDA_COMMON_H_
#define TVM_RUNTIME_CUDA_CUDA_COMMON_H_
#include <tvm/runtime/config.h>
#include <cuda_runtime.h>
#include <tvm/runtime/packed_func.h>
#include <string>
#if TVM_CUDA_RUNTIME
#include <cuda_runtime.h>
#include "../workspace_pool.h"
namespace tvm {
......@@ -49,5 +46,4 @@ class CUDAThreadEntry {
};
} // namespace runtime
} // namespace tvm
#endif // TVM_CUDA_RUNTIME
#endif // TVM_RUNTIME_CUDA_CUDA_COMMON_H_
......@@ -3,10 +3,8 @@
* \file cuda_device_api.cc
* \brief GPU specific API
*/
#include <tvm/runtime/config.h>
#include <tvm/runtime/device_api.h>
#if TVM_CUDA_RUNTIME
#include <dmlc/logging.h>
#include <dmlc/thread_local.h>
#include <tvm/runtime/registry.h>
......@@ -204,4 +202,3 @@ TVM_REGISTER_GLOBAL("device_api.gpu")
} // namespace runtime
} // namespace tvm
#endif // TVM_CUDA_RUNTIME
......@@ -4,8 +4,6 @@
*/
#include "./cuda_module.h"
#if TVM_CUDA_RUNTIME
#include <tvm/runtime/registry.h>
#include <cuda.h>
#include <cuda_runtime.h>
......@@ -305,4 +303,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_cuda")
});
} // namespace runtime
} // namespace tvm
#endif // TVM_CUDA_RUNTIME
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_CUDA_CUDA_MODULE_H_
#define TVM_RUNTIME_CUDA_CUDA_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/module.h>
#include <memory>
#include <vector>
......
......@@ -13,7 +13,6 @@
#import <Metal/MTLDevice.h>
#import <Metal/MTLLibrary.h>
#include <tvm/runtime/config.h>
#include <tvm/runtime/c_runtime_api.h>
#include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h>
......
......@@ -2,11 +2,9 @@
* Copyright (c) 2017 by Contributors
* \file metal_device_api.mm
*/
#include "./metal_common.h"
#if TVM_METAL_RUNTIME
#include <tvm/runtime/registry.h>
#include <dmlc/thread_local.h>
#include "./metal_common.h"
namespace tvm {
namespace runtime {
......@@ -289,5 +287,3 @@ TVM_REGISTER_GLOBAL("device_api.metal")
} // namespace metal
} // namespace runtime
} // namespace tvm
#endif // TVM_METAL_RUNTIME
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_METAL_METAL_MODULE_H_
#define TVM_RUNTIME_METAL_METAL_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/packed_func.h>
#include <memory>
#include <vector>
......
......@@ -2,16 +2,13 @@
* Copyright (c) 2017 by Contributors
* \file metal_module.cc
*/
#include "./metal_module.h"
#if TVM_METAL_RUNTIME
#include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h>
#include <tvm/runtime/module.h>
#include <array>
#include <string>
#include <mutex>
#include "./metal_module.h"
#include "./metal_common.h"
#include "../pack_args.h"
#include "../thread_storage_scope.h"
......@@ -304,4 +301,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_metal")
});
} // namespace runtime
} // namespace tvm
#endif // TVM_METAL_RUNTIME
......@@ -6,13 +6,11 @@
#ifndef TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_
#define TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/c_runtime_api.h>
#include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h>
#include <dmlc/logging.h>
#if TVM_OPENCL_RUNTIME
#ifdef __APPLE__
#include <OpenCL/opencl.h>
#else
......@@ -192,5 +190,4 @@ class OpenCLThreadEntry {
} // namespace cl
} // namespace runtime
} // namespace tvm
#endif // TVM_OPENCL_RUNTIME
#endif // TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_
......@@ -2,12 +2,9 @@
* Copyright (c) 2017 by Contributors
* \file opencl_device_api.cc
*/
#include "./opencl_common.h"
#if TVM_OPENCL_RUNTIME
#include <tvm/runtime/registry.h>
#include <dmlc/thread_local.h>
#include "./opencl_common.h"
namespace tvm {
namespace runtime {
......@@ -277,5 +274,3 @@ TVM_REGISTER_GLOBAL("device_api.opencl")
} // namespace cl
} // namespace runtime
} // namespace tvm
#endif // TVM_OPENCL_RUNTIME
......@@ -2,16 +2,14 @@
* Copyright (c) 2017 by Contributors
* \file opencl_module.cc
*/
#include "./opencl_common.h"
#include "./opencl_module.h"
#if TVM_OPENCL_RUNTIME
#include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h>
#include <vector>
#include <string>
#include <unordered_map>
#include "./opencl_common.h"
#include "./opencl_module.h"
#include "../pack_args.h"
#include "../thread_storage_scope.h"
#include "../meta_data.h"
......@@ -318,5 +316,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opencl")
});
} // namespace runtime
} // namespace tvm
#endif // TVM_OPENCL_RUNTIME
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_
#define TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/packed_func.h>
#include <memory>
#include <vector>
......
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_OPENGL_OPENGL_COMMON_H_
#define TVM_RUNTIME_OPENGL_OPENGL_COMMON_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/c_runtime_api.h>
#include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h>
......
......@@ -2,13 +2,10 @@
* Copyright (c) 2017 by Contributors
* \file opengl_device_api.cc
*/
#include "./opengl_common.h"
#include "./opengl_module.h"
#if TVM_OPENGL_RUNTIME
#include <tvm/runtime/registry.h>
#include <cstring>
#include "./opengl_common.h"
#include "./opengl_module.h"
namespace tvm {
namespace runtime {
......@@ -613,5 +610,3 @@ TVM_REGISTER_GLOBAL("device_api.opengl")
} // namespace gl
} // namespace runtime
} // namespace tvm
#endif // TVM_OPENGL_RUNTIME
......@@ -2,14 +2,10 @@
* Copyright (c) 2017 by Contributors
* \file opengl_module.cc
*/
#include <tvm/runtime/registry.h>
#include <utility>
#include "./opengl_common.h"
#include "./opengl_module.h"
#if TVM_OPENGL_RUNTIME
#include <tvm/runtime/registry.h>
#include "../pack_args.h"
#include "../thread_storage_scope.h"
#include "../file_util.h"
......@@ -280,5 +276,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opengl")
} // namespace runtime
} // namespace tvm
#endif // TVM_OPENGL_RUNTIME
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_OPENGL_OPENGL_MODULE_H_
#define TVM_RUNTIME_OPENGL_OPENGL_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/packed_func.h>
#include <algorithm>
#include <memory>
......
......@@ -6,12 +6,9 @@
#ifndef TVM_RUNTIME_ROCM_ROCM_COMMON_H_
#define TVM_RUNTIME_ROCM_ROCM_COMMON_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/packed_func.h>
#include <string>
#if TVM_ROCM_RUNTIME
#include <hip/hip_runtime_api.h>
#include <string>
#include "../workspace_pool.h"
namespace tvm {
......@@ -47,5 +44,4 @@ class ROCMThreadEntry {
};
} // namespace runtime
} // namespace tvm
#endif // TVM_ROCM_RUNTIME
#endif // TVM_RUNTIME_ROCM_ROCM_COMMON_H_
......@@ -3,10 +3,8 @@
* \file rocm_device_api.cc
* \brief GPU specific API
*/
#include <tvm/runtime/config.h>
#include <tvm/runtime/device_api.h>
#if TVM_ROCM_RUNTIME
#include <dmlc/logging.h>
#include <dmlc/thread_local.h>
#include <tvm/runtime/registry.h>
......@@ -162,4 +160,3 @@ TVM_REGISTER_GLOBAL("device_api.rocm")
} // namespace runtime
} // namespace tvm
#endif // TVM_ROCM_RUNTIME
......@@ -2,16 +2,13 @@
* Copyright (c) 2017 by Contributors
* \file rocm_module.cc
*/
#include "./rocm_module.h"
#if TVM_ROCM_RUNTIME
#include <tvm/runtime/registry.h>
#include <hip/hip_runtime_api.h>
#include <vector>
#include <array>
#include <string>
#include <mutex>
#include "./rocm_module.h"
#include "./rocm_common.h"
#include "../pack_args.h"
#include "../thread_storage_scope.h"
......@@ -237,4 +234,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_hip")
});
} // namespace runtime
} // namespace tvm
#endif // TVM_ROCM_RUNTIME
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_ROCM_ROCM_MODULE_H_
#define TVM_RUNTIME_ROCM_ROCM_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/module.h>
#include <memory>
#include <vector>
......
......@@ -6,14 +6,11 @@
#ifndef TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_
#define TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/c_runtime_api.h>
#include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h>
#include <dmlc/logging.h>
#if TVM_VULKAN_RUNTIME
#include <vulkan/vulkan.h>
#include <mutex>
#include <string>
......@@ -281,5 +278,4 @@ class VulkanThreadEntry {
} // namespace vulkan
} // namespace runtime
} // namespace tvm
#endif // TVM_VULKAN_RUNTIME
#endif // TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_
......@@ -2,14 +2,10 @@
* Copyright (c) 2017 by Contributors
* \file vulkan_device_api.cc
*/
#include "./vulkan_common.h"
#if TVM_VULKAN_RUNTIME
#include <tvm/runtime/registry.h>
#include <dmlc/thread_local.h>
#include <cstring>
#include "./vulkan_common.h"
namespace tvm {
namespace runtime {
......@@ -693,5 +689,3 @@ TVM_REGISTER_GLOBAL("device_api.vulkan")
} // namespace vulkan
} // namespace runtime
} // namespace tvm
#endif // TVM_VULKAN_RUNTIME
......@@ -2,10 +2,6 @@
* Copyright (c) 2018 by Contributors
* \file vulkan_module.cc
*/
#include "./vulkan_module.h"
#if TVM_VULKAN_RUNTIME
#include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h>
#include <tvm/runtime/module.h>
......@@ -13,6 +9,7 @@
#include <string>
#include <mutex>
#include "./vulkan_common.h"
#include "./vulkan_module.h"
#include "../pack_args.h"
#include "../thread_storage_scope.h"
#include "../meta_data.h"
......@@ -421,4 +418,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_vulkan")
});
} // namespace runtime
} // namespace tvm
#endif // TVM_VULKAN_RUNTIME
......@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_VULKAN_VULKAN_MODULE_H_
#define TVM_RUNTIME_VULKAN_VULKAN_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/packed_func.h>
#include <dmlc/type_traits.h>
#include <memory>
......
#!/bin/bash
echo "Build TVM..."
make "$@"
cd nnvm
echo "Build NNVM..."
make "$@"
cd $1 && cmake .. && make $2 && cd ..
#!/bin/bash
echo "Cleanup data..."
cd nnvm
make clean
cd ..
make clean
rm -rf $1
#!/bin/bash
export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH}
make test -j8 || exit -1
for test in tests/cpp/*_test; do
make cpptest -j8 || exit -1
for test in build/*_test; do
./$test || exit -1
done
#!/bin/bash
export PYTHONPATH=python:apps/extension/python
export PYTHONPATH=${PYTHONPATH}:apps/graph_executor/python:apps/graph_executor/nnvm/python
export PYTHONPATH=python
export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH}
CURR_DIR=$(cd `dirname $0`; pwd)
......
#!/bin/bash
export PYTHONPATH=python:apps/extension/python
export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH}
export LD_LIBRARY_PATH=build:${LD_LIBRARY_PATH}
rm -rf python/tvm/*.pyc python/tvm/*/*.pyc
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment