Commit 2d3031ee by Tianqi Chen Committed by GitHub

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

parent cd39697e
...@@ -172,16 +172,19 @@ cscope* ...@@ -172,16 +172,19 @@ cscope*
# TVM generated code # TVM generated code
perf perf
.bash_history
*.json *.json
*.params *.params
*.onnx *.onnx
*.h5 *.h5
synset.txt synset.txt
cat.jpg cat.jpg
docs.tgz
cat.png
*.mlmodel
# Mac OS X # Mac OS X
.DS_Store .DS_Store
build*
# Jetbrain # Jetbrain
.idea .idea
cmake_minimum_required(VERSION 3.7) cmake_minimum_required(VERSION 3.5)
project(tvm C CXX) project(tvm C CXX)
# Utility functions
include(cmake/util/Util.cmake)
include(cmake/util/FindLLVM.cmake)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake)
include(${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake) include(${CMAKE_CURRENT_SOURCE_DIR}/build/private/local_config.cmake)
endif() endif()
include(cmake/Util.cmake)
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake) if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake) include(${CMAKE_CURRENT_BINARY_DIR}/config.cmake)
else() else()
...@@ -19,31 +21,43 @@ endif() ...@@ -19,31 +21,43 @@ endif()
# You can create a config.cmake at build folder # You can create a config.cmake at build folder
# and add set(OPTION VALUE) to override these build options. # and add set(OPTION VALUE) to override these build options.
# Alernatively, use cmake -DOPTION=VALUE through command-line. # Alernatively, use cmake -DOPTION=VALUE through command-line.
tvm_option(USE_CUDA "Build with CUDA" OFF) tvm_option(USE_CUDA "Build with CUDA" OFF)
tvm_option(USE_OPENCL "Build with OpenCL" OFF) tvm_option(USE_OPENCL "Build with OpenCL" OFF)
tvm_option(USE_VULKAN "Build with Vulkan" OFF) tvm_option(USE_VULKAN "Build with Vulkan" OFF)
tvm_option(USE_OPENGL "Build with OpenGL" OFF) tvm_option(USE_OPENGL "Build with OpenGL" OFF)
tvm_option(USE_METAL "Build with Metal" OFF) tvm_option(USE_METAL "Build with Metal" OFF)
tvm_option(USE_ROCM "Build with ROCM" OFF)
tvm_option(ROCM_PATH "The path to rocm" /opt/rocm)
tvm_option(USE_RPC "Build with RPC" ON) tvm_option(USE_RPC "Build with RPC" ON)
tvm_option(USE_LLVM "Build with LLVM, can be set to specific llvm-config path" OFF)
tvm_option(USE_GRAPH_RUNTIME "Build with tiny graph runtime" ON) tvm_option(USE_GRAPH_RUNTIME "Build with tiny graph runtime" ON)
tvm_option(USE_LLVM "Build with LLVM" OFF) tvm_option(USE_GRAPH_RUNTIME_DEBUG "Build with tiny graph runtime debug mode" OFF)
tvm_option(USE_RTTI "Build with RTTI" ON) tvm_option(USE_RTTI "Build with RTTI" ON)
tvm_option(USE_MSVC_MT "Build with MT" OFF) tvm_option(USE_MSVC_MT "Build with MT" OFF)
tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF) tvm_option(INSTALL_DEV "Install compiler infrastructure" OFF)
# Contrib library options
tvm_option(USE_BLAS "The blas library to be linked" none)
tvm_option(USE_CUDNN "Build with cuDNN" OFF) tvm_option(USE_CUDNN "Build with cuDNN" OFF)
tvm_option(USE_CUBLAS "Build with cuBLAS" OFF)
tvm_option(USE_MIOPEN "Build with ROCM:MIOpen" OFF)
tvm_option(USE_ROCBLAS "Build with ROCM:RoCBLAS" OFF)
tvm_option(USE_SORT "Build with sort support" OFF)
tvm_option(USE_NNPACK "Build with nnpack support" OFF)
tvm_option(USE_RANDOM "Build with random support" OFF)
# include directories
include_directories(BEFORE "nnvm/include") include_directories(BEFORE "nnvm/include")
include_directories("include") include_directories("include")
include_directories("HalideIR/src") include_directories("HalideIR/src")
include_directories("dlpack/include") include_directories("dlpack/include")
include_directories("topi/include")
# initial variables
set(TVM_LINKER_LIBS "") set(TVM_LINKER_LIBS "")
set(TVM_RUNTIME_LINKER_LIBS "") set(TVM_RUNTIME_LINKER_LIBS "")
# compile # Generic compilation options
if(MSVC) if(MSVC)
add_definitions(-DWIN32_LEAN_AND_MEAN) add_definitions(-DWIN32_LEAN_AND_MEAN)
add_definitions(-D_CRT_SECURE_NO_WARNINGS) add_definitions(-D_CRT_SECURE_NO_WARNINGS)
...@@ -70,11 +84,12 @@ endif(MSVC) ...@@ -70,11 +84,12 @@ endif(MSVC)
# add source group # add source group
FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "HalideIR/src/*.cpp" "nnvm/src/*.cc") FILE(GLOB_RECURSE GROUP_SOURCE "src/*.cc" "HalideIR/src/*.cpp" "nnvm/src/*.cc")
FILE(GLOB_RECURSE GROUP_Include "src/*.h" "include/*.h" "HalideIR/src/*.h" FILE(GLOB_RECURSE GROUP_INCLUDE "src/*.h" "include/*.h" "HalideIR/src/*.h"
"nnvm/src/*.h" "nnvm/include/*.h") "nnvm/src/*.h" "nnvm/include/*.h")
assign_source_group("Source" ${GROUP_SOURCE}) assign_source_group("Source" ${GROUP_SOURCE})
assign_source_group("Include" ${GROUP_Include}) assign_source_group("Include" ${GROUP_INCLUDE})
# Source file lists
file(GLOB COMPILER_SRCS file(GLOB COMPILER_SRCS
src/api/*.cc src/api/*.cc
src/arithmetic/*.cc src/arithmetic/*.cc
...@@ -86,6 +101,11 @@ file(GLOB COMPILER_SRCS ...@@ -86,6 +101,11 @@ file(GLOB COMPILER_SRCS
src/schedule/*.cc src/schedule/*.cc
) )
if(NOT MSVC)
file(GLOB COMPILER_VERILOG_SRCS src/codegen/verilog/*.cc)
list(APPEND COMPILER_SRCS ${COMPILER_VERILOG_SRCS})
endif()
file(GLOB_RECURSE NNVM_COMPILER_SRCS file(GLOB_RECURSE NNVM_COMPILER_SRCS
nnvm/src/c_api/*.cc nnvm/src/c_api/*.cc
nnvm/src/core/*.cc nnvm/src/core/*.cc
...@@ -94,157 +114,34 @@ file(GLOB_RECURSE NNVM_COMPILER_SRCS ...@@ -94,157 +114,34 @@ file(GLOB_RECURSE NNVM_COMPILER_SRCS
nnvm/src/top/*.cc nnvm/src/top/*.cc
) )
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/topi/include)
file(GLOB TOPI_SRCS file(GLOB TOPI_SRCS
topi/src/*.cc topi/src/*.cc
) )
file(GLOB_RECURSE HALIDEIR_SRCS HalideIR/src/*.cpp) file(GLOB_RECURSE HALIDEIR_SRCS HalideIR/src/*.cpp)
list(APPEND COMPILER_SRCS ${HALIDEIR_SRCS}) list(APPEND COMPILER_SRCS ${HALIDEIR_SRCS})
file(GLOB RUNTIME_SRCS src/runtime/*.cc) file(GLOB RUNTIME_SRCS src/runtime/*.cc)
file(GLOB COMPILER_LLVM_SRCS src/codegen/llvm/*.cc)
file(GLOB COMPILER_VULKAN_SRCS src/codegen/spirv/*.cc)
file(GLOB RUNTIME_CUDA_SRCS src/runtime/cuda/*.cc)
file(GLOB RUNTIME_OPENCL_SRCS src/runtime/opencl/*.cc)
file(GLOB RUNTIME_OPENGL_SRCS src/runtime/opengl/*.cc)
file(GLOB RUNTIME_VULKAN_SRCS src/runtime/vulkan/*.cc)
file(GLOB RUNTIME_METAL_SRCS src/runtime/metal/*.mm)
file(GLOB RUNTIME_RPC_SRCS src/runtime/rpc/*.cc)
file(GLOB RUNTIME_GRAPH_SRCS src/runtime/graph/*.cc)
if(USE_CUDA)
find_package(CUDA)
# 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)
set(CUDA_CUDA_LIBRARY ${CUDA_CUDA_LIBRARIES})
find_package(CUDA QUIET REQUIRED) # Package runtime rules
message(STATUS "Build with CUDA support") if(NOT USE_RTTI)
include_directories(${CUDA_INCLUDE_DIRS}) add_definitions(-DDMLC_ENABLE_RTTI=0)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDART_LIBRARY}) endif()
list(APPEND TVM_RUNTIME_LINKER_LIBS ${CUDA_CUDA_LIBRARY})
list(APPEND RUNTIME_SRCS ${RUNTIME_CUDA_SRCS})
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)
add_definitions(-DTVM_CUDA_RUNTIME=1)
else(USE_CUDA)
add_definitions(-DTVM_CUDA_RUNTIME=0)
endif(USE_CUDA)
if(USE_OPENCL)
find_package(OpenCL QUIET REQUIRED)
message(STATUS "Build with OpenCL support")
include_directories(${OpenCL_INCLUDE_DIRS})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenCL_LIBRARIES})
list(APPEND RUNTIME_SRCS ${RUNTIME_OPENCL_SRCS})
add_definitions(-DTVM_OPENCL_RUNTIME=1)
else(USE_OPENCL)
add_definitions(-DTVM_OPENCL_RUNTIME=0)
endif(USE_OPENCL)
if(USE_OPENGL)
find_package(OpenGL QUIET REQUIRED)
find_package(glfw3 QUIET REQUIRED)
message(STATUS "Build with OpenGL support")
include_directories(${OPENGL_INCLUDE_DIRS})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${OpenGL_LIBRARIES} glfw)
list(APPEND RUNTIME_SRCS ${RUNTIME_OPENGL_SRCS})
add_definitions(-DTVM_OPENGL_RUNTIME=1)
else(USE_OPENGL)
add_definitions(-DTVM_OPENGL_RUNTIME=0)
endif(USE_OPENGL)
if(USE_VULKAN)
find_package(Vulkan REQUIRED)
message(STATUS "Build with VULKAN support")
include_directories(${Vulkan_INCLUDE_DIRS})
list(APPEND TVM_RUNTIME_LINKER_LIBS ${Vulkan_LIBRARIES})
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})
add_definitions(-DTVM_VULKAN_RUNTIME=1)
else(USE_VULKAN)
add_definitions(-DTVM_VULKAN_RUNTIME=0)
endif(USE_VULKAN)
if(USE_METAL)
find_package(OpenCL QUIET REQUIRED)
message(STATUS "Build with Metal support")
FIND_LIBRARY(METAL_LIB Metal)
FIND_LIBRARY(FOUNDATION_LIB Foundation)
list(APPEND TVM_RUNTIME_LINKER_LIBS ${METAL_LIB} ${FOUNDATION_LIB})
list(APPEND RUNTIME_SRCS ${RUNTIME_METAL_SRCS})
add_definitions(-DTVM_METAL_RUNTIME=1)
else(USE_METAL)
add_definitions(-DTVM_METAL_RUNTIME=0)
endif(USE_METAL)
if(USE_RPC) if(USE_RPC)
message(STATUS "Build with RPC support...") message(STATUS "Build with RPC support...")
file(GLOB RUNTIME_RPC_SRCS src/runtime/rpc/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_RPC_SRCS}) list(APPEND RUNTIME_SRCS ${RUNTIME_RPC_SRCS})
endif(USE_RPC) endif(USE_RPC)
if(USE_GRAPH_RUNTIME) if(USE_GRAPH_RUNTIME)
message(STATUS "Build with Graph runtime support...") message(STATUS "Build with Graph runtime support...")
file(GLOB RUNTIME_GRAPH_SRCS src/runtime/graph/*.cc)
list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_SRCS}) list(APPEND RUNTIME_SRCS ${RUNTIME_GRAPH_SRCS})
endif(USE_GRAPH_RUNTIME)
if(USE_LLVM)
find_package(LLVM CONFIG REQUIRED)
include_directories(${LLVM_INCLUDE_DIRS})
add_definitions(${LLVM_DEFINITIONS})
set(TVM_LLVM_VERSION ${LLVM_VERSION_MAJOR}${LLVM_VERSION_MINOR})
message(STATUS "Build with LLVM " ${LLVM_PACKAGE_VERSION})
message(STATUS "Set TVM_LLVM_VERSION=" ${TVM_LLVM_VERSION})
add_definitions(-DTVM_LLVM_VERSION=${TVM_LLVM_VERSION})
add_definitions(-DDMLC_USE_FOPEN64=0)
llvm_map_components_to_libnames(LLVM_LIBS all)
list(REMOVE_ITEM LLVM_LIBS LTO)
list(APPEND TVM_LINKER_LIBS ${LLVM_LIBS})
list(APPEND COMPILER_SRCS ${COMPILER_LLVM_SRCS})
if(NOT MSVC)
set_property(SOURCE ${COMPILER_LLVM_SRCS} APPEND_STRING PROPERTY COMPILE_FLAGS
"-fno-rtti -DDMLC_ENABLE_RTTI=0")
endif()
endif(USE_LLVM)
if(NOT USE_RTTI) if(USE_GRAPH_RUNTIME_DEBUG)
add_definitions(-DDMLC_ENABLE_RTTI=0) set_source_files_properties(${RUNTIME_GRAPH_SRCS}
endif() PROPERTIES COMPILE_DEFINITIONS "TVM_GRAPH_RUNTIME_DEBUG")
endif(USE_GRAPH_RUNTIME_DEBUG)
endif(USE_GRAPH_RUNTIME)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/CMakeLists.txt) if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/CMakeLists.txt)
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/include) include_directories(${CMAKE_CURRENT_SOURCE_DIR}/dmlc-core/include)
...@@ -259,18 +156,55 @@ elseif(DMLC_CORE_PATH) ...@@ -259,18 +156,55 @@ elseif(DMLC_CORE_PATH)
include_directories(${DMLC_CORE_PATH}/include) include_directories(${DMLC_CORE_PATH}/include)
endif() endif()
list(APPEND RUNTIME_SRCS ${GROUP_Include}) # Module rules
include(cmake/modules/CUDA.cmake)
include(cmake/modules/OpenCL.cmake)
include(cmake/modules/OpenGL.cmake)
include(cmake/modules/Vulkan.cmake)
include(cmake/modules/Metal.cmake)
include(cmake/modules/ROCM.cmake)
include(cmake/modules/LLVM.cmake)
include(cmake/modules/contrib/BLAS.cmake)
include(cmake/modules/contrib/Random.cmake)
include(cmake/modules/contrib/Sort.cmake)
include(cmake/modules/contrib/NNPack.cmake)
# Target rrules
add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS}) add_library(tvm SHARED ${COMPILER_SRCS} ${RUNTIME_SRCS})
add_library(tvm_topi SHARED ${TOPI_SRCS}) add_library(tvm_topi SHARED ${TOPI_SRCS})
add_library(tvm_runtime SHARED ${RUNTIME_SRCS}) add_library(tvm_runtime SHARED ${RUNTIME_SRCS})
add_library(nnvm_compiler SHARED ${NNVM_COMPILER_SRCS}) add_library(nnvm_compiler SHARED ${NNVM_COMPILER_SRCS})
target_link_libraries(tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}) target_link_libraries(tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(tvm_topi tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS}) target_link_libraries(tvm_topi tvm ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(tvm_runtime ${TVM_RUNTIME_LINKER_LIBS}) target_link_libraries(tvm_runtime ${TVM_RUNTIME_LINKER_LIBS})
target_link_libraries(nnvm_compiler tvm) target_link_libraries(nnvm_compiler tvm)
install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX}) # Tests
set(TEST_EXECS "")
file(GLOB TEST_SRCS tests/cpp/*.cc)
find_library(GTEST_LIB gtest)
if(GTEST_LIB)
foreach(__srcpath ${TEST_SRCS})
get_filename_component(__srcname ${__srcpath} NAME)
string(REPLACE ".cc" "" __execname ${__srcname})
add_executable(${__execname} ${__srcpath})
list(APPEND TEST_EXECS ${__execname})
target_link_libraries(${__execname}
tvm ${GTEST_LIB} ${TVM_LINKER_LIBS} ${TVM_RUNTIME_LINKER_LIBS} pthread)
set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_ALL 1)
set_target_properties(${__execname} PROPERTIES EXCLUDE_FROM_DEFAULT_BUILD 1)
endforeach()
add_custom_target(cpptest DEPENDS ${TEST_EXECS})
endif()
# Custom targets
add_custom_target(runtime DEPENDS tvm_runtime)
# Installation rulse
install(TARGETS tvm_runtime DESTINATION lib${LIB_SUFFIX})
if(WIN32) if(WIN32)
install(TARGETS nnvm_compiler RUNTIME DESTINATION bin) install(TARGETS nnvm_compiler RUNTIME DESTINATION bin)
install(TARGETS nnvm_compiler ARCHIVE DESTINATION lib) install(TARGETS nnvm_compiler ARCHIVE DESTINATION lib)
...@@ -313,6 +247,7 @@ else(INSTALL_DEV) ...@@ -313,6 +247,7 @@ else(INSTALL_DEV)
) )
endif(INSTALL_DEV) endif(INSTALL_DEV)
# More target definitions
if(MSVC) if(MSVC)
target_compile_definitions(tvm PRIVATE -DHalide_EXPORTS) target_compile_definitions(tvm PRIVATE -DHalide_EXPORTS)
target_compile_definitions(tvm_runtime PRIVATE -DHalide_EXPORTS) target_compile_definitions(tvm_runtime PRIVATE -DHalide_EXPORTS)
......
...@@ -4,11 +4,11 @@ ...@@ -4,11 +4,11 @@
// See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/ // See documents at https://jenkins.io/doc/book/pipeline/jenkinsfile/
// tvm libraries // tvm libraries
tvm_runtime = "lib/libtvm_runtime.so, config.mk" tvm_runtime = "build/libtvm_runtime.so, build/config.cmake"
tvm_lib = "lib/libtvm.so, " + tvm_runtime tvm_lib = "build/libtvm.so, " + tvm_runtime
// LLVM upstream lib // LLVM upstream lib
tvm_multilib = "lib/libtvm_llvm40.so, lib/libtvm_llvm50.so, lib/libtvm_llvm60.so, " + tvm_multilib = "build/libtvm.so, " +
"lib/libtvm_topi.so, nnvm/lib/libnnvm_compiler.so, " + tvm_runtime "build/libtvm_topi.so, build/libnnvm_compiler.so, " + tvm_runtime
// command to start a docker container // command to start a docker container
docker_run = 'tests/ci_build/ci_build.sh' docker_run = 'tests/ci_build/ci_build.sh'
...@@ -48,14 +48,14 @@ stage("Sanity Check") { ...@@ -48,14 +48,14 @@ stage("Sanity Check") {
// Run make. First try to do an incremental make from a previous workspace in hope to // 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 // accelerate the compilation. If something wrong, clean the workspace and then
// build from scratch. // build from scratch.
def make(docker_type, make_flag) { def make(docker_type, path, make_flag) {
timeout(time: max_time, unit: 'MINUTES') { timeout(time: max_time, unit: 'MINUTES') {
try { 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) { } catch (exc) {
echo 'Incremental compilation failed. Fall back to build from scratch' 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_clean.sh ${path}"
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}"
} }
} }
} }
...@@ -85,33 +85,30 @@ stage('Build') { ...@@ -85,33 +85,30 @@ stage('Build') {
ws('workspace/tvm/build-gpu') { ws('workspace/tvm/build-gpu') {
init_git() init_git()
sh """ sh """
cp make/config.mk . mkdir -p build
echo USE_CUDNN=1 >> config.mk cd build
echo USE_CUDA=1 >> config.mk cp ../cmake/config.cmake .
echo USE_OPENGL=1 >> config.mk echo set\\(USE_CUDNN ON\\) >> config.cmake
echo LLVM_CONFIG=llvm-config-4.0 >> config.mk echo set\\(USE_CUDA ON\\) >> config.cmake
echo USE_RPC=1 >> config.mk echo set\\(USE_OPENGL ON\\) >> config.cmake
echo USE_SORT=1 >> config.mk echo set\\(USE_LLVM llvm-config-6.0\\) >> config.cmake
echo USE_GRAPH_RUNTIME=1 >> config.mk echo set\\(USE_RPC ON\\) >> config.cmake
echo USE_BLAS=openblas >> config.mk echo set\\(USE_SORT ON\\) >> config.cmake
rm -f lib/libtvm_runtime.so lib/libtvm.so echo set\\(USE_GRAPH_RUNTIME ON\\) >> config.cmake
echo set\\(USE_BLAS openblas\\) >> config.cmake
""" """
make('gpu', '-j2') make('gpu', 'build', '-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"
pack_lib('gpu', tvm_multilib) pack_lib('gpu', tvm_multilib)
// compiler test
sh """ sh """
echo USE_OPENCL=1 >> config.mk mkdir -p build2
echo USE_ROCM=1 >> config.mk cd build2
echo ROCM_PATH=/opt/rocm >> config.mk cp ../cmake/config.cmake .
echo USE_VULKAN=1 >> config.mk 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') { ...@@ -120,17 +117,17 @@ stage('Build') {
ws('workspace/tvm/build-cpu') { ws('workspace/tvm/build-cpu') {
init_git() init_git()
sh """ sh """
cp make/config.mk . mkdir -p build
echo USE_CUDA=0 >> config.mk cd build
echo USE_OPENCL=0 >> config.mk cp ../cmake/config.cmake .
echo USE_RPC=0 >> config.mk echo set\\(USE_SORT ON\\) >> config.cmake
echo USE_SORT=1 >> config.mk echo set\\(USE_LLVM llvm-config-4.0\\) >> config.cmake
echo USE_OPENGL=1 >> config.mk
echo LLVM_CONFIG=llvm-config-4.0 >> config.mk
echo USE_SORT=1 >> config.mk
""" """
make('cpu', '-j2') make('cpu', 'build', '-j2')
pack_lib('cpu', tvm_lib) 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') { ...@@ -139,21 +136,14 @@ stage('Build') {
ws('workspace/tvm/build-i386') { ws('workspace/tvm/build-i386') {
init_git() init_git()
sh """ sh """
cp make/config.mk . mkdir -p build
echo USE_CUDA=0 >> config.mk cd build
echo USE_OPENCL=0 >> config.mk cp ../cmake/config.cmake .
echo LLVM_CONFIG=llvm-config-4.0 >> config.mk echo set\\(USE_SORT ON\\) >> config.cmake
echo USE_RPC=1 >> config.mk echo set\\(USE_RPC ON\\) >> config.cmake
echo USE_SORT=1 >> config.mk echo set\\(USE_LLVM llvm-config-5.0\\) >> config.cmake
""" """
make('i386', '-j2') make('i386', 'build', '-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"
pack_lib('i386', tvm_multilib) pack_lib('i386', tvm_multilib)
} }
} }
...@@ -166,12 +156,6 @@ stage('Unit Test') { ...@@ -166,12 +156,6 @@ stage('Unit Test') {
ws('workspace/tvm/ut-python-gpu') { ws('workspace/tvm/ut-python-gpu') {
init_git() init_git()
unpack_lib('gpu', tvm_multilib) 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') { timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_unittest.sh" sh "${docker_run} gpu ./tests/scripts/task_python_unittest.sh"
} }
...@@ -183,27 +167,10 @@ stage('Unit Test') { ...@@ -183,27 +167,10 @@ stage('Unit Test') {
ws('workspace/tvm/ut-python-i386') { ws('workspace/tvm/ut-python-i386') {
init_git() init_git()
unpack_lib('i386', tvm_multilib) unpack_lib('i386', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') { timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} i386 ./tests/scripts/task_python_unittest.sh" sh "${docker_run} i386 ./tests/scripts/task_python_unittest.sh"
sh "${docker_run} i386 ./tests/scripts/task_python_integration.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') { ...@@ -212,7 +179,6 @@ stage('Unit Test') {
ws('workspace/tvm/ut-java') { ws('workspace/tvm/ut-java') {
init_git() init_git()
unpack_lib('gpu', tvm_multilib) unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') { timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_java_unittest.sh" sh "${docker_run} gpu ./tests/scripts/task_java_unittest.sh"
} }
...@@ -227,7 +193,6 @@ stage('Integration Test') { ...@@ -227,7 +193,6 @@ stage('Integration Test') {
ws('workspace/tvm/it-python-gpu') { ws('workspace/tvm/it-python-gpu') {
init_git() init_git()
unpack_lib('gpu', tvm_multilib) unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') { timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_integration.sh" sh "${docker_run} gpu ./tests/scripts/task_python_integration.sh"
sh "${docker_run} gpu ./tests/scripts/task_python_topi.sh" sh "${docker_run} gpu ./tests/scripts/task_python_topi.sh"
...@@ -242,7 +207,6 @@ stage('Integration Test') { ...@@ -242,7 +207,6 @@ stage('Integration Test') {
ws('workspace/tvm/docs-python-gpu') { ws('workspace/tvm/docs-python-gpu') {
init_git() init_git()
unpack_lib('gpu', tvm_multilib) unpack_lib('gpu', tvm_multilib)
sh "cp lib/libtvm_llvm40.so lib/libtvm.so"
timeout(time: max_time, unit: 'MINUTES') { timeout(time: max_time, unit: 'MINUTES') {
sh "${docker_run} gpu ./tests/scripts/task_python_docs.sh" sh "${docker_run} gpu ./tests/scripts/task_python_docs.sh"
} }
......
ROOTDIR = $(CURDIR) ROOTDIR = $(CURDIR)
ifndef config .PHONY: clean all test doc pylint cpplint lint\
ifneq ("$(wildcard ./config.mk)","") cython cython2 cython3 web runtime
config ?= config.mk
else
config ?= make/config.mk
endif
endif
include $(config)
.PHONY: clean install installdev all test doc pylint cpplint lint\
verilog cython cython2 cython3 web topi nnvm runtime
ifndef DMLC_CORE_PATH ifndef DMLC_CORE_PATH
DMLC_CORE_PATH = $(ROOTDIR)/dmlc-core DMLC_CORE_PATH = $(ROOTDIR)/dmlc-core
...@@ -21,316 +11,42 @@ ifndef DLPACK_PATH ...@@ -21,316 +11,42 @@ ifndef DLPACK_PATH
DLPACK_PATH = $(ROOTDIR)/dlpack DLPACK_PATH = $(ROOTDIR)/dlpack
endif endif
UNAME_S := $(shell uname -s)
# The flags
LLVM_CFLAGS= -fno-rtti -DDMLC_ENABLE_RTTI=0 -DDMLC_USE_FOPEN64=0
LDFLAGS = -pthread -lm -ldl -Wl,-Bsymbolic-functions
INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include INCLUDE_FLAGS = -Iinclude -I$(DLPACK_PATH)/include -I$(DMLC_CORE_PATH)/include -IHalideIR/src -Itopi/include
CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC PKG_CFLAGS = -std=c++11 -Wall -O2 $(INCLUDE_FLAGS) -fPIC
PKG_LDFLAGS = PKG_LDFLAGS =
FRAMEWORKS =
OBJCFLAGS = -fno-objc-arc
EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
-Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
-s TOTAL_MEMORY=1073741824\
-s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\
-s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\
$(INCLUDE_FLAGS)
# llvm configuration
ifdef LLVM_CONFIG
LLVM_VERSION=$(shell $(LLVM_CONFIG) --version| cut -b 1,3)
LLVM_INCLUDE=$(filter -I%, $(shell $(LLVM_CONFIG) --cxxflags))
LDFLAGS += $(shell $(LLVM_CONFIG) --ldflags --libs --system-libs)
LLVM_CFLAGS += $(LLVM_INCLUDE) -DTVM_LLVM_VERSION=$(LLVM_VERSION)
else
LLVM_VERSION=00
endif
# The source code dependencies
LIB_HALIDEIR = HalideIR/lib/libHalideIR.a
CC_SRC = $(filter-out src/contrib/%.cc src/runtime/%.cc src/codgen/llvm/%.cc,\
$(wildcard src/*/*.cc src/*/*/*.cc))
LLVM_SRC = $(wildcard src/codegen/llvm/*.cc src/codegen/llvm/*/*.cc)
METAL_SRC = $(wildcard src/runtime/metal/*.mm)
CUDA_SRC = $(wildcard src/runtime/cuda/*.cc)
ROCM_SRC = $(wildcard src/runtime/rocm/*.cc)
OPENCL_SRC = $(wildcard src/runtime/opencl/*.cc)
OPENGL_SRC = $(wildcard src/runtime/opengl/*.cc)
VULKAN_SRC = $(wildcard src/runtime/vulkan/*.cc)
SGX_SRC = $(wildcard src/runtime/sgx/untrusted/*.cc)
RPC_SRC = $(wildcard src/runtime/rpc/*.cc)
GRAPH_SRC = $(wildcard src/runtime/graph/*.cc)
RUNTIME_SRC = $(wildcard src/runtime/*.cc)
# TOPI
TOPI_SRC = $(wildcard topi/src/*.cc)
# Objectives
LLVM_BUILD = build/llvm${LLVM_VERSION}
LLVM_OBJ = $(patsubst src/%.cc, ${LLVM_BUILD}/%.o, $(LLVM_SRC))
METAL_OBJ = $(patsubst src/%.mm, build/%.o, $(METAL_SRC))
CUDA_OBJ = $(patsubst src/%.cc, build/%.o, $(CUDA_SRC))
ROCM_OBJ = $(patsubst src/%.cc, build/%.o, $(ROCM_SRC))
OPENCL_OBJ = $(patsubst src/%.cc, build/%.o, $(OPENCL_SRC))
OPENGL_OBJ = $(patsubst src/%.cc, build/%.o, $(OPENGL_SRC))
VULKAN_OBJ = $(patsubst src/%.cc, build/%.o, $(VULKAN_SRC))
SGX_OBJ = $(patsubst src/%.cc, build/%.o, $(SGX_SRC)) build/runtime/sgx/untrusted/tvm_u.o
RPC_OBJ = $(patsubst src/%.cc, build/%.o, $(RPC_SRC))
GRAPH_OBJ = $(patsubst src/%.cc, build/%.o, $(GRAPH_SRC))
CC_OBJ = $(patsubst src/%.cc, build/%.o, $(CC_SRC)) $(LLVM_OBJ)
RUNTIME_OBJ = $(patsubst src/%.cc, build/%.o, $(RUNTIME_SRC))
TOPI_OBJ = $(patsubst topi/src/%.cc, build/topi/%.o, $(TOPI_SRC))
CONTRIB_OBJ =
# Deps
ALL_DEP = $(CC_OBJ) $(CONTRIB_OBJ) $(LIB_HALIDEIR)
RUNTIME_DEP = $(RUNTIME_OBJ)
TOPI_DEP = $(TOPI_OBJ)
ifeq ($(UNAME_S), Darwin)
PKG_LDFLAGS += -undefined dynamic_lookup
endif
# Dependency specific rules
ifdef CUDA_PATH
NVCC=$(CUDA_PATH)/bin/nvcc
CFLAGS += -I$(CUDA_PATH)/include
ifeq ($(UNAME_S),Darwin)
LDFLAGS += -L$(CUDA_PATH)/lib
else
LDFLAGS += -L$(CUDA_PATH)/lib64
endif
endif
ifeq ($(USE_CUDA), 1)
CFLAGS += -DTVM_CUDA_RUNTIME=1
LDFLAGS += -lcuda -lcudart -lnvrtc
RUNTIME_DEP += $(CUDA_OBJ)
else
CFLAGS += -DTVM_CUDA_RUNTIME=0
endif
ifdef ROCM_PATH
CFLAGS += -I$(ROCM_PATH)/include
LDFLAGS += -L$(ROCM_PATH)/lib
endif
ifeq ($(USE_ROCM), 1)
CFLAGS += -DTVM_ROCM_RUNTIME=1 -D__HIP_PLATFORM_HCC__=1
LDFLAGS += -lhip_hcc
RUNTIME_DEP += $(ROCM_OBJ)
else
CFLAGS += -DTVM_ROCM_RUNTIME=0
endif
ifeq ($(USE_OPENCL), 1)
CFLAGS += -DTVM_OPENCL_RUNTIME=1
ifeq ($(UNAME_S), Darwin)
FRAMEWORKS += -framework OpenCL
else
LDFLAGS += -lOpenCL
endif
RUNTIME_DEP += $(OPENCL_OBJ)
ifdef OPENCL_PATH
CFLAGS += -I$(OPENCL_PATH)/include
LDFLAGS += -L$(OPENCL_PATH)/lib
endif
else
CFLAGS += -DTVM_OPENCL_RUNTIME=0
endif
ifdef VULKAN_SDK
CFLAGS += -I$(VULKAN_SDK)/include
LDFLAGS += -L$(VULKAN_SDK)/lib
LDFLAGS += -L$(VULKAN_SDK)/lib/spirv-tools
endif
ifeq ($(USE_VULKAN), 1)
CFLAGS += -DTVM_VULKAN_RUNTIME=1
LDFLAGS += -lvulkan -lSPIRV-Tools
RUNTIME_DEP += $(VULKAN_OBJ)
else
CFLAGS += -DTVM_VULKAN_RUNTIME=0
endif
ifeq ($(USE_OPENGL), 1)
CFLAGS += -DTVM_OPENGL_RUNTIME=1
EMCC_FLAGS += -DTVM_OPENGL_RUNTIME=1
ifeq ($(UNAME_S), Darwin)
FRAMEWORKS += -framework OpenGL
else
LDFLAGS += -lGL -lglfw
endif
RUNTIME_DEP += $(OPENGL_OBJ)
else
CFLAGS += -DTVM_OPENGL_RUNTIME=0
endif
ifeq ($(USE_METAL), 1) all:
CFLAGS += -DTVM_METAL_RUNTIME=1 @mkdir -p build && cd build && cmake .. && $(MAKE)
LDFLAGS += -lobjc
RUNTIME_DEP += $(METAL_OBJ)
FRAMEWORKS += -framework Metal -framework Foundation
else
CFLAGS += -DTVM_METAL_RUNTIME=0
endif
ifeq ($(USE_SGX), 1) runtime:
EDGER8R = $(SGX_SDK)/bin/x64/sgx_edger8r
ifneq ($(SGX_MODE), HW)
sgx_sim := _sim
endif
urts_library_name := sgx_urts$(sgx_sim)
CFLAGS += -DTVM_SGX_RUNTIME=1
SGX_CFLAGS = -include "build/runtime/sgx/untrusted/tvm_u.h" -I$(SGX_SDK)/include
LDFLAGS += -L$(SGX_SDK)/lib64 -l$(urts_library_name)
RUNTIME_DEP += $(SGX_OBJ)
else
CFLAGS += -DTVM_SGX_RUNTIME=0
endif
ifeq ($(USE_RPC), 1) @mkdir -p build && cd build && cmake .. && $(MAKE) runtime
RUNTIME_DEP += $(RPC_OBJ)
endif
ifeq ($(USE_GRAPH_RUNTIME), 1)
RUNTIME_DEP += $(GRAPH_OBJ)
endif
ifeq ($(USE_GRAPH_RUNTIME_DEBUG), 1) cpptest:
CFLAGS += -DTVM_GRAPH_RUNTIME_DEBUG @mkdir -p build && cd build && cmake .. && $(MAKE) cpptest
endif
include make/contrib/cblas.mk # EMCC; Web related scripts
include make/contrib/sort.mk EMCC_FLAGS= -std=c++11 -DDMLC_LOG_STACK_TRACE=0\
include make/contrib/random.mk -Oz -s RESERVED_FUNCTION_POINTERS=2 -s MAIN_MODULE=1 -s NO_EXIT_RUNTIME=1\
include make/contrib/nnpack.mk -s TOTAL_MEMORY=1073741824\
include make/contrib/cudnn.mk -s EXTRA_EXPORTED_RUNTIME_METHODS="['cwrap','getValue','setValue','addFunction']"\
include make/contrib/miopen.mk -s USE_GLFW=3 -s USE_WEBGL2=1 -lglfw\
include make/contrib/mps.mk $(INCLUDE_FLAGS)
include make/contrib/cublas.mk
include make/contrib/rocblas.mk
ifdef ADD_CFLAGS
CFLAGS += $(ADD_CFLAGS)
endif
ifdef ADD_LDFLAGS
LDFLAGS += $(ADD_LDFLAGS)
endif
ifeq ($(OS),Windows_NT)
JVM_PKG_PROFILE := windows
SHARED_LIBRARY_SUFFIX := dll
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
JVM_PKG_PROFILE := osx-x86_64
SHARED_LIBRARY_SUFFIX := dylib
else
JVM_PKG_PROFILE := linux-x86_64
SHARED_LIBRARY_SUFFIX := so
endif
endif
JVM_TEST_ARGS := $(if $(JVM_TEST_ARGS),$(JVM_TEST_ARGS),-DskipTests -Dcheckstyle.skip=true)
ifeq ($(USE_CUDA), 1)
JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu
else ifeq ($(USE_OPENCL), 1)
JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu
else ifeq ($(USE_METAL), 1)
JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu
else
JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-cpu
endif
BUILD_TARGETS ?= lib/libtvm.$(SHARED_LIBRARY_SUFFIX) \
lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) \
lib/libtvm_topi.$(SHARED_LIBRARY_SUFFIX)
all: ${BUILD_TARGETS}
runtime: lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX)
web: lib/libtvm_web_runtime.js lib/libtvm_web_runtime.bc
topi: lib/libtvm_topi.$(SHARED_LIBRARY_SUFFIX)
nnvm:
$(MAKE) -C nnvm
include tests/cpp/unittest.mk
test: $(TEST)
include verilog/verilog.mk
verilog: $(VER_LIBS)
# Special rules for LLVM related modules.
${LLVM_BUILD}/codegen/llvm/%.o: src/codegen/llvm/%.cc
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(LLVM_CFLAGS) -MM -MT ${LLVM_BUILD}/codegen/llvm/$*.o $< >${LLVM_BUILD}/codegen/llvm/$*.d
$(CXX) -c $(CFLAGS) $(LLVM_CFLAGS) -c $< -o $@
build/runtime/metal/%.o: src/runtime/metal/%.mm
@mkdir -p $(@D)
$(CXX) $(OBJCFLAGS) $(CFLAGS) -MM -MT build/runtime/metal/$*.o $< >build/runtime/metal/$*.d
$(CXX) $(OBJCFLAGS) -c $(CFLAGS) -c $< -o $@
build/runtime/sgx/untrusted/tvm_u.h: src/runtime/sgx/tvm.edl
@mkdir -p $(@D)
$(EDGER8R) $< --untrusted --untrusted-dir $(@D) --search-path $(SGX_SDK)/include
mv $@ $@.in
awk 'NR==4{print "#include <tvm/runtime/c_runtime_api.h>"}1' $@.in > $@
build/runtime/sgx/untrusted/tvm_u.c: build/runtime/sgx/untrusted/tvm_u.h
build/runtime/sgx/untrusted/tvm_u.o: build/runtime/sgx/untrusted/tvm_u.c
$(CC) $(CFLAGS) $(SGX_CFLAGS) -c $< -o $@
build/runtime/sgx/untrusted/%.o: src/runtime/sgx/untrusted/%.cc build/runtime/sgx/untrusted/tvm_u.h
$(CXX) $(CFLAGS) $(SGX_CFLAGS) -MM -MT build/$*.o $< >build/$*.d
$(CXX) -c $(CFLAGS) $(SGX_CFLAGS) -c $< -o $@
build/%.o: src/%.cc
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -MM -MT build/$*.o $< >build/$*.d
$(CXX) -c $(CFLAGS) -c $< -o $@
build/topi/%.o: topi/src/%.cc
@mkdir -p $(@D)
$(CXX) $(CFLAGS) -MM -MT build/topi/$*.o $< >build/topi/$*.d
$(CXX) -c $(CFLAGS) -c $< -o $@
lib/libtvm.${SHARED_LIBRARY_SUFFIX}: $(ALL_DEP) $(RUNTIME_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
lib/libtvm_topi.${SHARED_LIBRARY_SUFFIX}: $(TOPI_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS) $(PKG_LDFLAGS)
lib/libtvm_runtime.${SHARED_LIBRARY_SUFFIX}: $(RUNTIME_DEP)
@mkdir -p $(@D)
$(CXX) $(CFLAGS) $(FRAMEWORKS) -shared -o $@ $(filter %.o %.a, $^) $(LDFLAGS)
web: build/libtvm_web_runtime.js build/libtvm_web_runtime.bc
lib/libtvm_web_runtime.bc: web/web_runtime.cc build/libtvm_web_runtime.bc: web/web_runtime.cc
@mkdir -p build/web @mkdir -p build/web
@mkdir -p $(@D) @mkdir -p $(@D)
emcc $(EMCC_FLAGS) -MM -MT lib/libtvm_web_runtime.bc $< >build/web/web_runtime.d emcc $(EMCC_FLAGS) -MM -MT build/libtvm_web_runtime.bc $< >build/web/web_runtime.d
emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc emcc $(EMCC_FLAGS) -o $@ web/web_runtime.cc
lib/libtvm_web_runtime.js: lib/libtvm_web_runtime.bc build/libtvm_web_runtime.js: build/libtvm_web_runtime.bc
@mkdir -p $(@D) @mkdir -p $(@D)
emcc $(EMCC_FLAGS) -o $@ lib/libtvm_web_runtime.bc emcc $(EMCC_FLAGS) -o $@ build/libtvm_web_runtime.bc
$(LIB_HALIDEIR): LIBHALIDEIR
LIBHALIDEIR:
+ cd HalideIR; make lib/libHalideIR.a DMLC_CORE_PATH=../dmlc-core; cd $(ROOTDIR)
# Lint scripts
cpplint: cpplint:
python dmlc-core/scripts/lint.py topi cpp topi/include; python dmlc-core/scripts/lint.py topi cpp topi/include;
python dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src; python dmlc-core/scripts/lint.py nnvm cpp nnvm/include nnvm/src;
...@@ -350,18 +66,6 @@ lint: cpplint pylint jnilint ...@@ -350,18 +66,6 @@ lint: cpplint pylint jnilint
doc: doc:
doxygen docs/Doxyfile doxygen docs/Doxyfile
install: lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX)
mkdir -p $(DESTDIR)$(PREFIX)/include/tvm/runtime
cp -R include/tvm/runtime/. $(DESTDIR)$(PREFIX)/include/tvm/runtime
cp lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) $(DESTDIR)$(PREFIX)/lib
installdev: lib/libtvm.$(SHARED_LIBRARY_SUFFIX) lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) lib/libtvm.a
mkdir -p $(DESTDIR)$(PREFIX)/include
cp -R include/tvm $(DESTDIR)$(PREFIX)/include
cp lib/libtvm.$(SHARED_LIBRARY_SUFFIX) $(DESTDIR)$(PREFIX)/lib
cp lib/libtvm_runtime.$(SHARED_LIBRARY_SUFFIX) $(DESTDIR)$(PREFIX)/lib
cp lib/libtvm.a $(DESTDIR)$(PREFIX)/lib
# Cython build # Cython build
cython: cython:
cd python; python setup.py build_ext --inplace cd python; python setup.py build_ext --inplace
...@@ -375,23 +79,35 @@ cython3: ...@@ -375,23 +79,35 @@ cython3:
cyclean: cyclean:
rm -rf python/tvm/*/*/*.so python/tvm/*/*/*.dylib python/tvm/*/*/*.cpp rm -rf python/tvm/*/*/*.so python/tvm/*/*/*.dylib python/tvm/*/*/*.cpp
# JVM build rules
ifeq ($(OS),Windows_NT)
JVM_PKG_PROFILE := windows
SHARED_LIBRARY_SUFFIX := dll
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
JVM_PKG_PROFILE := osx-x86_64
SHARED_LIBRARY_SUFFIX := dylib
else
JVM_PKG_PROFILE := linux-x86_64
SHARED_LIBRARY_SUFFIX := so
endif
endif
JVM_TEST_ARGS := $(if $(JVM_TEST_ARGS),$(JVM_TEST_ARGS),-DskipTests -Dcheckstyle.skip=true)
JVM_PKG_PROFILE := $(JVM_PKG_PROFILE)-gpu
jvmpkg: jvmpkg:
(cd $(ROOTDIR)/jvm; \ (cd $(ROOTDIR)/jvm; \
mvn clean package -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \ mvn clean package -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \ -Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/lib" $(JVM_TEST_ARGS)) -Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS))
jvminstall: jvminstall:
(cd $(ROOTDIR)/jvm; \ (cd $(ROOTDIR)/jvm; \
mvn install -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \ mvn install -P$(JVM_PKG_PROFILE) -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \ -Dcflags="$(PKG_CFLAGS)" -Dldflags="$(PKG_LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/lib" $(JVM_TEST_ARGS)) -Dcurrent_libdir="$(ROOTDIR)/build" $(JVM_TEST_ARGS))
# clean rule
clean: clean:
$(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o */*.d */*/*.d */*/*/*.d $(RM) -rf build lib bin *~ */*~ */*/*~ */*/*/*~ */*.o */*/*.o */*/*/*.o */*.d */*/*.d */*/*/*.d
cd HalideIR; make clean; cd $(ROOTDIR)
$(MAKE) -C nnvm clean
-include build/*.d
-include build/*/*.d
-include build/*/*/*.d
-include build/*/*/*/*.d
#--------------------------------------------------------------------
# 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. # An option that the user can select. Can accept condition to control when option is available for user.
# Usage: # Usage:
# tvm_option(<option_variable> "doc string" <initial value or boolean expression> [IF <condition>]) # 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(__value ${value})
set(__condition "") set(__condition "")
set(__varname "__value") set(__varname "__value")
...@@ -21,23 +27,23 @@ function(tvm_option variable description value) ...@@ -21,23 +27,23 @@ function(tvm_option variable description value)
if(${__condition}) if(${__condition})
if("${__value}" MATCHES ";") if("${__value}" MATCHES ";")
if(${__value}) if(${__value})
option(${variable} "${description}" ON) __tvm_option(${variable} "${description}" ON)
else() else()
option(${variable} "${description}" OFF) __tvm_option(${variable} "${description}" OFF)
endif() endif()
elseif(DEFINED ${__value}) elseif(DEFINED ${__value})
if(${__value}) if(${__value})
option(${variable} "${description}" ON) __tvm_option(${variable} "${description}" ON)
else() else()
option(${variable} "${description}" OFF) __tvm_option(${variable} "${description}" OFF)
endif() endif()
else() else()
option(${variable} "${description}" ${__value}) __tvm_option(${variable} "${description}" "${__value}")
endif() endif()
else() else()
unset(${variable} CACHE) unset(${variable} CACHE)
endif() endif()
endfunction() endmacro()
function(assign_source_group group) function(assign_source_group group)
foreach(_source IN ITEMS ${ARGN}) foreach(_source IN ITEMS ${ARGN})
...@@ -50,4 +56,4 @@ function(assign_source_group group) ...@@ -50,4 +56,4 @@ function(assign_source_group group)
string(REPLACE "/" "\\" _source_path_msvc "${_source_path}") string(REPLACE "/" "\\" _source_path_msvc "${_source_path}")
source_group("${group}\\${_source_path_msvc}" FILES "${_source}") source_group("${group}\\${_source_path_msvc}" FILES "${_source}")
endforeach() endforeach()
endfunction(assign_source_group) endfunction(assign_source_group)
\ No newline at end of file
...@@ -38,13 +38,23 @@ Our goal is to build the shared libraries: ...@@ -38,13 +38,23 @@ Our goal is to build the shared libraries:
The minimal building requirements are The minimal building requirements are
- A recent c++ compiler supporting C++ 11 (g++-4.8 or higher) - 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. - 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 - 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. - 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` ...@@ -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 - 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). [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/) - You can also use [LLVM Nightly Ubuntu Build](https://apt.llvm.org/)
- Note that apt-package append ``llvm-config`` with version number. - 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
make -j4
After we build tvm, we can proceed to build nnvm using the following command.
.. code:: bash
make nnvm -j4 - We can then build tvm and related libraries.
.. code:: bash
cd build
cmake ..
make -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. If everything goes well, we can go to the specific language installation section.
...@@ -101,7 +106,7 @@ Building ROCm support ...@@ -101,7 +106,7 @@ Building ROCm support
Currently, ROCm is supported only on linux, so all the instructions are written with linux in mind. 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. - 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. - 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 ...@@ -71,9 +71,8 @@ sudo ldconfig
git clone --recursive https://github.com/dmlc/tvm 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 `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 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 @@ ...@@ -6,7 +6,7 @@
<includeBaseDirectory>false</includeBaseDirectory> <includeBaseDirectory>false</includeBaseDirectory>
<files> <files>
<file> <file>
<source>../../../lib/libtvm_runtime.so</source> <source>../../../build/libtvm_runtime.so</source>
<outputDirectory>lib/native</outputDirectory> <outputDirectory>lib/native</outputDirectory>
<fileMode>0644</fileMode> <fileMode>0644</fileMode>
</file> </file>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<includeBaseDirectory>false</includeBaseDirectory> <includeBaseDirectory>false</includeBaseDirectory>
<files> <files>
<file> <file>
<source>../../../lib/libtvm_runtime.so</source> <source>../../../build/libtvm_runtime.so</source>
<outputDirectory>lib/native</outputDirectory> <outputDirectory>lib/native</outputDirectory>
<fileMode>0644</fileMode> <fileMode>0644</fileMode>
</file> </file>
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<includeBaseDirectory>false</includeBaseDirectory> <includeBaseDirectory>false</includeBaseDirectory>
<files> <files>
<file> <file>
<source>../../../lib/libtvm_runtime.dylib</source> <source>../../../build/libtvm_runtime.dylib</source>
<outputDirectory>lib/native</outputDirectory> <outputDirectory>lib/native</outputDirectory>
<fileMode>0644</fileMode> <fileMode>0644</fileMode>
</file> </file>
......
...@@ -81,7 +81,7 @@ ...@@ -81,7 +81,7 @@
<consoleOutput>true</consoleOutput> <consoleOutput>true</consoleOutput>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.7</version> <version>2.7</version>
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
<threadCount>1</threadCount> <threadCount>1</threadCount>
<argLine> <argLine>
-Djava.library.path=${project.parent.basedir}/native/${platform}/target -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> </argLine>
</configuration> </configuration>
<executions> <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 @@ ...@@ -3,7 +3,6 @@
* \file codegen_cuda.cc * \file codegen_cuda.cc
*/ */
#include <tvm/base.h> #include <tvm/base.h>
#include <tvm/runtime/config.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <tvm/packed_func_ext.h> #include <tvm/packed_func_ext.h>
#include <vector> #include <vector>
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file codegen_metal.cc * \file codegen_metal.cc
*/ */
#include <tvm/runtime/config.h>
#include <tvm/packed_func_ext.h> #include <tvm/packed_func_ext.h>
#include <vector> #include <vector>
#include <string> #include <string>
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file codegen_opencl.cc * \file codegen_opencl.cc
*/ */
#include <tvm/runtime/config.h>
#include <tvm/packed_func_ext.h> #include <tvm/packed_func_ext.h>
#include <vector> #include <vector>
#include <string> #include <string>
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
* We are targeting OpenGL 3.3. The reason of not targeting a recent version * We are targeting OpenGL 3.3. The reason of not targeting a recent version
* of OpenGL is to have better compatibility of WebGL 2. * of OpenGL is to have better compatibility of WebGL 2.
*/ */
#include <tvm/runtime/config.h>
#include <tvm/packed_func_ext.h> #include <tvm/packed_func_ext.h>
#include <vector> #include <vector>
#include <string> #include <string>
......
...@@ -105,7 +105,6 @@ class CodeGenAMDGPU : public CodeGenLLVM { ...@@ -105,7 +105,6 @@ class CodeGenAMDGPU : public CodeGenLLVM {
llvm::Value* CreateStorageSync(const Call* op) final { llvm::Value* CreateStorageSync(const Call* op) final {
const std::string& sync = op->args[0].as<StringImm>()->value; const std::string& sync = op->args[0].as<StringImm>()->value;
if (sync == "warp") { if (sync == "warp") {
// TODO(tqchen) warp sync in CUDA9
return nullptr; return nullptr;
} else if (sync == "shared") { } else if (sync == "shared") {
llvm::Function* f = llvm::Intrinsic::getDeclaration( llvm::Function* f = llvm::Intrinsic::getDeclaration(
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
* \brief NVPTX code generator. * \brief NVPTX code generator.
*/ */
#ifdef TVM_LLVM_VERSION #ifdef TVM_LLVM_VERSION
#if TVM_CUDA_RUNTIME
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
#include "./codegen_llvm.h" #include "./codegen_llvm.h"
...@@ -215,5 +214,4 @@ TVM_REGISTER_API("codegen.build_nvptx") ...@@ -215,5 +214,4 @@ TVM_REGISTER_API("codegen.build_nvptx")
} // namespace codegen } // namespace codegen
} // namespace tvm } // namespace tvm
#endif // TVM_CUDA_RUNTIME
#endif // TVM_LLVM_VERSION #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 * Copyright (c) 2017 by Contributors
* Build cuda modules from source. * Build cuda modules from source.
* requires cuda to be available.
*
* \file build_cuda.cc * \file build_cuda.cc
*/ */
#include <tvm/base.h> #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 <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 tvm {
namespace codegen { namespace codegen {
...@@ -79,4 +79,3 @@ TVM_REGISTER_API("codegen.build_cuda") ...@@ -79,4 +79,3 @@ TVM_REGISTER_API("codegen.build_cuda")
}); });
} // namespace codegen } // namespace codegen
} // namespace tvm } // namespace tvm
#endif // TVM_CUDA_RUNTIME
/*! /*!
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* Build metal modules from source. * Build metal modules from source.
* \file build_metal.cc * \file build_metal.h
*/ */
#include <tvm/base.h> #ifndef TVM_CODEGEN_OPT_BUILD_METAL_H_
#include <tvm/runtime/config.h> #define TVM_CODEGEN_OPT_BUILD_METAL_H_
#include "./codegen_metal.h"
#include "./build_common.h" #include <string>
#include "../codegen_metal.h"
#include "../build_common.h"
#if TVM_METAL_RUNTIME #if TVM_METAL_RUNTIME
#include "../runtime/metal/metal_module.h" #include "../../runtime/metal/metal_module.h"
#endif // TVM_METAL_RUNTIME #endif // TVM_METAL_RUNTIME
namespace tvm { namespace tvm {
...@@ -45,3 +47,4 @@ TVM_REGISTER_API("codegen.build_metal") ...@@ -45,3 +47,4 @@ TVM_REGISTER_API("codegen.build_metal")
}); });
} // namespace codegen } // namespace codegen
} // namespace tvm } // 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 * Copyright (c) 2017 by Contributors
* Build opencl modules from source. * 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/base.h>
#include <tvm/runtime/config.h> #include <string>
#include "./codegen_opencl.h" #include "../codegen_opencl.h"
#include "./build_common.h" #include "../build_common.h"
#if TVM_OPENCL_RUNTIME #if TVM_OPENCL_RUNTIME
#include "../runtime/opencl/opencl_module.h" #include "../../runtime/opencl/opencl_module.h"
#endif // TVM_OPENCL_RUNTIME #endif // TVM_OPENCL_RUNTIME
namespace tvm { namespace tvm {
...@@ -42,3 +45,4 @@ TVM_REGISTER_API("codegen.build_opencl") ...@@ -42,3 +45,4 @@ TVM_REGISTER_API("codegen.build_opencl")
}); });
} // namespace codegen } // namespace codegen
} // namespace tvm } // 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 * Copyright (c) 2017 by Contributors
* Build opengl modules from source. * 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 <tvm/base.h>
#include "./codegen_opengl.h" #include "../codegen_opengl.h"
#include "./build_common.h" #include "../build_common.h"
namespace tvm { namespace tvm {
namespace codegen { namespace codegen {
...@@ -33,3 +36,4 @@ TVM_REGISTER_API("codegen.build_opengl") ...@@ -33,3 +36,4 @@ TVM_REGISTER_API("codegen.build_opengl")
}); });
} // namespace codegen } // namespace codegen
} // namespace tvm } // 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 @@ ...@@ -6,12 +6,9 @@
#ifndef TVM_RUNTIME_CUDA_CUDA_COMMON_H_ #ifndef TVM_RUNTIME_CUDA_CUDA_COMMON_H_
#define 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 <tvm/runtime/packed_func.h>
#include <string> #include <string>
#if TVM_CUDA_RUNTIME
#include <cuda_runtime.h>
#include "../workspace_pool.h" #include "../workspace_pool.h"
namespace tvm { namespace tvm {
...@@ -49,5 +46,4 @@ class CUDAThreadEntry { ...@@ -49,5 +46,4 @@ class CUDAThreadEntry {
}; };
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_CUDA_RUNTIME
#endif // TVM_RUNTIME_CUDA_CUDA_COMMON_H_ #endif // TVM_RUNTIME_CUDA_CUDA_COMMON_H_
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
* \file cuda_device_api.cc * \file cuda_device_api.cc
* \brief GPU specific API * \brief GPU specific API
*/ */
#include <tvm/runtime/config.h>
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
#if TVM_CUDA_RUNTIME
#include <dmlc/logging.h> #include <dmlc/logging.h>
#include <dmlc/thread_local.h> #include <dmlc/thread_local.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
...@@ -204,4 +202,3 @@ TVM_REGISTER_GLOBAL("device_api.gpu") ...@@ -204,4 +202,3 @@ TVM_REGISTER_GLOBAL("device_api.gpu")
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_CUDA_RUNTIME
...@@ -4,8 +4,6 @@ ...@@ -4,8 +4,6 @@
*/ */
#include "./cuda_module.h" #include "./cuda_module.h"
#if TVM_CUDA_RUNTIME
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <cuda.h> #include <cuda.h>
#include <cuda_runtime.h> #include <cuda_runtime.h>
...@@ -305,4 +303,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_cuda") ...@@ -305,4 +303,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_cuda")
}); });
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_CUDA_RUNTIME
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_CUDA_CUDA_MODULE_H_ #ifndef TVM_RUNTIME_CUDA_CUDA_MODULE_H_
#define TVM_RUNTIME_CUDA_CUDA_MODULE_H_ #define TVM_RUNTIME_CUDA_CUDA_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/module.h> #include <tvm/runtime/module.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
......
...@@ -13,7 +13,6 @@ ...@@ -13,7 +13,6 @@
#import <Metal/MTLDevice.h> #import <Metal/MTLDevice.h>
#import <Metal/MTLLibrary.h> #import <Metal/MTLLibrary.h>
#include <tvm/runtime/config.h>
#include <tvm/runtime/c_runtime_api.h> #include <tvm/runtime/c_runtime_api.h>
#include <tvm/runtime/packed_func.h> #include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
......
...@@ -2,11 +2,9 @@ ...@@ -2,11 +2,9 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file metal_device_api.mm * \file metal_device_api.mm
*/ */
#include "./metal_common.h"
#if TVM_METAL_RUNTIME
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <dmlc/thread_local.h> #include <dmlc/thread_local.h>
#include "./metal_common.h"
namespace tvm { namespace tvm {
namespace runtime { namespace runtime {
...@@ -289,5 +287,3 @@ TVM_REGISTER_GLOBAL("device_api.metal") ...@@ -289,5 +287,3 @@ TVM_REGISTER_GLOBAL("device_api.metal")
} // namespace metal } // namespace metal
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_METAL_RUNTIME
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_METAL_METAL_MODULE_H_ #ifndef TVM_RUNTIME_METAL_METAL_MODULE_H_
#define 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 <tvm/runtime/packed_func.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
......
...@@ -2,16 +2,13 @@ ...@@ -2,16 +2,13 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file metal_module.cc * \file metal_module.cc
*/ */
#include "./metal_module.h"
#if TVM_METAL_RUNTIME
#include <dmlc/memory_io.h> #include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <tvm/runtime/module.h> #include <tvm/runtime/module.h>
#include <array> #include <array>
#include <string> #include <string>
#include <mutex> #include <mutex>
#include "./metal_module.h"
#include "./metal_common.h" #include "./metal_common.h"
#include "../pack_args.h" #include "../pack_args.h"
#include "../thread_storage_scope.h" #include "../thread_storage_scope.h"
...@@ -304,4 +301,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_metal") ...@@ -304,4 +301,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_metal")
}); });
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_METAL_RUNTIME
...@@ -6,13 +6,11 @@ ...@@ -6,13 +6,11 @@
#ifndef TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ #ifndef TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_
#define 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/c_runtime_api.h>
#include <tvm/runtime/packed_func.h> #include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
#include <dmlc/logging.h> #include <dmlc/logging.h>
#if TVM_OPENCL_RUNTIME
#ifdef __APPLE__ #ifdef __APPLE__
#include <OpenCL/opencl.h> #include <OpenCL/opencl.h>
#else #else
...@@ -192,5 +190,4 @@ class OpenCLThreadEntry { ...@@ -192,5 +190,4 @@ class OpenCLThreadEntry {
} // namespace cl } // namespace cl
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_OPENCL_RUNTIME
#endif // TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_ #endif // TVM_RUNTIME_OPENCL_OPENCL_COMMON_H_
...@@ -2,12 +2,9 @@ ...@@ -2,12 +2,9 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file opencl_device_api.cc * \file opencl_device_api.cc
*/ */
#include "./opencl_common.h"
#if TVM_OPENCL_RUNTIME
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <dmlc/thread_local.h> #include <dmlc/thread_local.h>
#include "./opencl_common.h"
namespace tvm { namespace tvm {
namespace runtime { namespace runtime {
...@@ -277,5 +274,3 @@ TVM_REGISTER_GLOBAL("device_api.opencl") ...@@ -277,5 +274,3 @@ TVM_REGISTER_GLOBAL("device_api.opencl")
} // namespace cl } // namespace cl
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_OPENCL_RUNTIME
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file opencl_module.cc * \file opencl_module.cc
*/ */
#include "./opencl_common.h"
#include "./opencl_module.h"
#if TVM_OPENCL_RUNTIME
#include <dmlc/memory_io.h> #include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <vector> #include <vector>
#include <string> #include <string>
#include <unordered_map> #include <unordered_map>
#include "./opencl_common.h"
#include "./opencl_module.h"
#include "../pack_args.h" #include "../pack_args.h"
#include "../thread_storage_scope.h" #include "../thread_storage_scope.h"
#include "../meta_data.h" #include "../meta_data.h"
...@@ -318,5 +316,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opencl") ...@@ -318,5 +316,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opencl")
}); });
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_OPENCL_RUNTIME
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_ #ifndef TVM_RUNTIME_OPENCL_OPENCL_MODULE_H_
#define 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 <tvm/runtime/packed_func.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
......
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_OPENGL_OPENGL_COMMON_H_ #ifndef TVM_RUNTIME_OPENGL_OPENGL_COMMON_H_
#define 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/c_runtime_api.h>
#include <tvm/runtime/packed_func.h> #include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
......
...@@ -2,13 +2,10 @@ ...@@ -2,13 +2,10 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file opengl_device_api.cc * \file opengl_device_api.cc
*/ */
#include "./opengl_common.h"
#include "./opengl_module.h"
#if TVM_OPENGL_RUNTIME
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <cstring> #include <cstring>
#include "./opengl_common.h"
#include "./opengl_module.h"
namespace tvm { namespace tvm {
namespace runtime { namespace runtime {
...@@ -613,5 +610,3 @@ TVM_REGISTER_GLOBAL("device_api.opengl") ...@@ -613,5 +610,3 @@ TVM_REGISTER_GLOBAL("device_api.opengl")
} // namespace gl } // namespace gl
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_OPENGL_RUNTIME
...@@ -2,14 +2,10 @@ ...@@ -2,14 +2,10 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file opengl_module.cc * \file opengl_module.cc
*/ */
#include <tvm/runtime/registry.h>
#include <utility> #include <utility>
#include "./opengl_common.h" #include "./opengl_common.h"
#include "./opengl_module.h" #include "./opengl_module.h"
#if TVM_OPENGL_RUNTIME
#include <tvm/runtime/registry.h>
#include "../pack_args.h" #include "../pack_args.h"
#include "../thread_storage_scope.h" #include "../thread_storage_scope.h"
#include "../file_util.h" #include "../file_util.h"
...@@ -280,5 +276,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opengl") ...@@ -280,5 +276,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_opengl")
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_OPENGL_RUNTIME
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_OPENGL_OPENGL_MODULE_H_ #ifndef TVM_RUNTIME_OPENGL_OPENGL_MODULE_H_
#define 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 <tvm/runtime/packed_func.h>
#include <algorithm> #include <algorithm>
#include <memory> #include <memory>
......
...@@ -6,12 +6,9 @@ ...@@ -6,12 +6,9 @@
#ifndef TVM_RUNTIME_ROCM_ROCM_COMMON_H_ #ifndef TVM_RUNTIME_ROCM_ROCM_COMMON_H_
#define 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 <tvm/runtime/packed_func.h>
#include <string>
#if TVM_ROCM_RUNTIME
#include <hip/hip_runtime_api.h> #include <hip/hip_runtime_api.h>
#include <string>
#include "../workspace_pool.h" #include "../workspace_pool.h"
namespace tvm { namespace tvm {
...@@ -19,17 +16,17 @@ namespace runtime { ...@@ -19,17 +16,17 @@ namespace runtime {
#define ROCM_DRIVER_CALL(x) \ #define ROCM_DRIVER_CALL(x) \
{ \ { \
hipError_t result = x; \ hipError_t result = x; \
if (result != hipSuccess && result != hipErrorDeinitialized) { \ if (result != hipSuccess && result != hipErrorDeinitialized) { \
LOG(FATAL) \ LOG(FATAL) \
<< "ROCM HIP Error: " #x " failed with error: " << hipGetErrorString(result); \ << "ROCM HIP Error: " #x " failed with error: " << hipGetErrorString(result); \
} \ } \
} }
#define ROCM_CALL(func) \ #define ROCM_CALL(func) \
{ \ { \
hipError_t e = (func); \ hipError_t e = (func); \
CHECK(e == hipSuccess) \ CHECK(e == hipSuccess) \
<< "ROCM HIP: " << hipGetErrorString(e); \ << "ROCM HIP: " << hipGetErrorString(e); \
} }
...@@ -47,5 +44,4 @@ class ROCMThreadEntry { ...@@ -47,5 +44,4 @@ class ROCMThreadEntry {
}; };
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_ROCM_RUNTIME
#endif // TVM_RUNTIME_ROCM_ROCM_COMMON_H_ #endif // TVM_RUNTIME_ROCM_ROCM_COMMON_H_
...@@ -3,10 +3,8 @@ ...@@ -3,10 +3,8 @@
* \file rocm_device_api.cc * \file rocm_device_api.cc
* \brief GPU specific API * \brief GPU specific API
*/ */
#include <tvm/runtime/config.h>
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
#if TVM_ROCM_RUNTIME
#include <dmlc/logging.h> #include <dmlc/logging.h>
#include <dmlc/thread_local.h> #include <dmlc/thread_local.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
...@@ -162,4 +160,3 @@ TVM_REGISTER_GLOBAL("device_api.rocm") ...@@ -162,4 +160,3 @@ TVM_REGISTER_GLOBAL("device_api.rocm")
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_ROCM_RUNTIME
...@@ -2,16 +2,13 @@ ...@@ -2,16 +2,13 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file rocm_module.cc * \file rocm_module.cc
*/ */
#include "./rocm_module.h"
#if TVM_ROCM_RUNTIME
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <hip/hip_runtime_api.h> #include <hip/hip_runtime_api.h>
#include <vector> #include <vector>
#include <array> #include <array>
#include <string> #include <string>
#include <mutex> #include <mutex>
#include "./rocm_module.h"
#include "./rocm_common.h" #include "./rocm_common.h"
#include "../pack_args.h" #include "../pack_args.h"
#include "../thread_storage_scope.h" #include "../thread_storage_scope.h"
...@@ -237,4 +234,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_hip") ...@@ -237,4 +234,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_hip")
}); });
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_ROCM_RUNTIME
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_ROCM_ROCM_MODULE_H_ #ifndef TVM_RUNTIME_ROCM_ROCM_MODULE_H_
#define TVM_RUNTIME_ROCM_ROCM_MODULE_H_ #define TVM_RUNTIME_ROCM_ROCM_MODULE_H_
#include <tvm/runtime/config.h>
#include <tvm/runtime/module.h> #include <tvm/runtime/module.h>
#include <memory> #include <memory>
#include <vector> #include <vector>
......
...@@ -6,14 +6,11 @@ ...@@ -6,14 +6,11 @@
#ifndef TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_ #ifndef TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_
#define 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/c_runtime_api.h>
#include <tvm/runtime/packed_func.h> #include <tvm/runtime/packed_func.h>
#include <tvm/runtime/device_api.h> #include <tvm/runtime/device_api.h>
#include <dmlc/logging.h> #include <dmlc/logging.h>
#if TVM_VULKAN_RUNTIME
#include <vulkan/vulkan.h> #include <vulkan/vulkan.h>
#include <mutex> #include <mutex>
#include <string> #include <string>
...@@ -281,5 +278,4 @@ class VulkanThreadEntry { ...@@ -281,5 +278,4 @@ class VulkanThreadEntry {
} // namespace vulkan } // namespace vulkan
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_VULKAN_RUNTIME
#endif // TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_ #endif // TVM_RUNTIME_VULKAN_VULKAN_COMMON_H_
...@@ -2,14 +2,10 @@ ...@@ -2,14 +2,10 @@
* Copyright (c) 2017 by Contributors * Copyright (c) 2017 by Contributors
* \file vulkan_device_api.cc * \file vulkan_device_api.cc
*/ */
#include "./vulkan_common.h"
#if TVM_VULKAN_RUNTIME
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <dmlc/thread_local.h> #include <dmlc/thread_local.h>
#include <cstring> #include <cstring>
#include "./vulkan_common.h"
namespace tvm { namespace tvm {
namespace runtime { namespace runtime {
...@@ -693,5 +689,3 @@ TVM_REGISTER_GLOBAL("device_api.vulkan") ...@@ -693,5 +689,3 @@ TVM_REGISTER_GLOBAL("device_api.vulkan")
} // namespace vulkan } // namespace vulkan
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_VULKAN_RUNTIME
...@@ -2,10 +2,6 @@ ...@@ -2,10 +2,6 @@
* Copyright (c) 2018 by Contributors * Copyright (c) 2018 by Contributors
* \file vulkan_module.cc * \file vulkan_module.cc
*/ */
#include "./vulkan_module.h"
#if TVM_VULKAN_RUNTIME
#include <dmlc/memory_io.h> #include <dmlc/memory_io.h>
#include <tvm/runtime/registry.h> #include <tvm/runtime/registry.h>
#include <tvm/runtime/module.h> #include <tvm/runtime/module.h>
...@@ -13,6 +9,7 @@ ...@@ -13,6 +9,7 @@
#include <string> #include <string>
#include <mutex> #include <mutex>
#include "./vulkan_common.h" #include "./vulkan_common.h"
#include "./vulkan_module.h"
#include "../pack_args.h" #include "../pack_args.h"
#include "../thread_storage_scope.h" #include "../thread_storage_scope.h"
#include "../meta_data.h" #include "../meta_data.h"
...@@ -421,4 +418,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_vulkan") ...@@ -421,4 +418,3 @@ TVM_REGISTER_GLOBAL("module.loadbinary_vulkan")
}); });
} // namespace runtime } // namespace runtime
} // namespace tvm } // namespace tvm
#endif // TVM_VULKAN_RUNTIME
...@@ -6,7 +6,6 @@ ...@@ -6,7 +6,6 @@
#ifndef TVM_RUNTIME_VULKAN_VULKAN_MODULE_H_ #ifndef TVM_RUNTIME_VULKAN_VULKAN_MODULE_H_
#define 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 <tvm/runtime/packed_func.h>
#include <dmlc/type_traits.h> #include <dmlc/type_traits.h>
#include <memory> #include <memory>
......
#!/bin/bash #!/bin/bash
echo "Build TVM..." cd $1 && cmake .. && make $2 && cd ..
make "$@"
cd nnvm
echo "Build NNVM..."
make "$@"
#!/bin/bash #!/bin/bash
echo "Cleanup data..." echo "Cleanup data..."
cd nnvm rm -rf $1
make clean
cd ..
make clean
#!/bin/bash #!/bin/bash
export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH}
make test -j8 || exit -1 make cpptest -j8 || exit -1
for test in tests/cpp/*_test; do for test in build/*_test; do
./$test || exit -1 ./$test || exit -1
done done
#!/bin/bash #!/bin/bash
export PYTHONPATH=python:apps/extension/python export PYTHONPATH=python
export PYTHONPATH=${PYTHONPATH}:apps/graph_executor/python:apps/graph_executor/nnvm/python
export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH} export LD_LIBRARY_PATH=lib:${LD_LIBRARY_PATH}
CURR_DIR=$(cd `dirname $0`; pwd) CURR_DIR=$(cd `dirname $0`; pwd)
......
#!/bin/bash #!/bin/bash
export PYTHONPATH=python:apps/extension/python 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 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