diff --git a/3rdparty/tvm b/3rdparty/tvm index adb14fd3f..b16fca2c6 160000 --- a/3rdparty/tvm +++ b/3rdparty/tvm @@ -1 +1 @@ -Subproject commit adb14fd3fb035436971ab0081dfaf1fb813e0f44 +Subproject commit b16fca2c66f1cfae2ac9b22d1bec6d1c3005d238 diff --git a/CMakeLists.txt b/CMakeLists.txt index 04a0000fa..c7993b913 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required (VERSION 3.6) include(cmake/Utils.cmake) -include(3rdparty/tvm/cmake/util/Util.cmake) -include(3rdparty/tvm/cmake/util/FindCUDA.cmake) +include(3rdparty/tvm/cmake/utils/Utils.cmake) +include(3rdparty/tvm/cmake/utils/FindCUDA.cmake) # Option for Android on Arm --- has to come before project() function option(ANDROID_BUILD "Build for Android target" OFF) @@ -213,68 +213,14 @@ if(USE_TENSORRT) include_directories(${TENSORRT_INCLUDE_DIR}) list(APPEND DLR_LINKER_LIBS ${TENSORRT_LIB_DIR}) - # NNVM TRT Integration - file(GLOB TENSORRT_SRCS ${TVM_SRC}/src/contrib/subgraph/*.cc) - list(APPEND DLR_SRC ${TENSORRT_SRCS}) + # TRT runtime sources + file(GLOB RUNTIME_TENSORRT_SRCS ${TVM_SRC}/src/runtime/contrib/tensorrt/*.cc) + set_source_files_properties(${RUNTIME_TENSORRT_SRCS} PROPERTIES COMPILE_FLAGS "-Wno-deprecated-declarations") + list(APPEND DLR_SRC ${RUNTIME_TENSORRT_SRCS}) + + # Set defines add_definitions(-DTVM_GRAPH_RUNTIME_TENSORRT) - # TRT Relay sources - file(GLOB TENSORRT_RELAY_SRCS ${TVM_SRC}/src/runtime/contrib/tensorrt/*.cc) - list(APPEND DLR_SRC ${TENSORRT_RELAY_SRCS}) - # Additional TVM compiler sources - include_directories("${TVM_SRC}/3rdparty/rang/include") - include_directories("${TVM_SRC}/3rdparty/compiler-rt") - include_directories("${TVM_SRC}/topi/include") - file(GLOB_RECURSE COMPILER_SRCS - ${TVM_SRC}/src/auto_scheduler/*.cc - ${TVM_SRC}/src/node/*.cc - ${TVM_SRC}/src/ir/*.cc - ${TVM_SRC}/src/arith/*.cc - ${TVM_SRC}/src/te/*.cc - ${TVM_SRC}/src/autotvm/*.cc - ${TVM_SRC}/src/tir/*.cc - ${TVM_SRC}/src/topi/*.cc - ${TVM_SRC}/src/driver/*.cc - ${TVM_SRC}/src/parser/*.cc - ${TVM_SRC}/src/printer/*.cc - ${TVM_SRC}/src/support/*.cc - ) - file(GLOB CODEGEN_SRCS - ${TVM_SRC}/src/target/*.cc - ${TVM_SRC}/src/target/source/*.cc - ) - list(APPEND COMPILER_SRCS ${CODEGEN_SRCS}) - file(GLOB_RECURSE RELAY_OP_SRCS - ${TVM_SRC}/src/relay/op/*.cc - ) - file(GLOB_RECURSE RELAY_PASS_SRCS - ${TVM_SRC}/src/relay/analysis/*.cc - ${TVM_SRC}/src/relay/transforms/*.cc - ${TVM_SRC}/src/relay/quantize/*.cc - ) - file(GLOB RELAY_BACKEND_SRCS - ${TVM_SRC}/src/relay/backend/*.cc - ${TVM_SRC}/src/relay/backend/vm/*.cc - ) - file(GLOB_RECURSE RELAY_IR_SRCS - ${TVM_SRC}/src/relay/ir/*.cc - ) - file(GLOB_RECURSE RELAY_QNN_SRCS - ${TVM_SRC}/src/relay/qnn/*.cc - ) - list(APPEND COMPILER_SRCS ${RELAY_OP_SRCS}) - list(APPEND COMPILER_SRCS ${RELAY_PASS_SRCS}) - list(APPEND COMPILER_SRCS ${RELAY_BACKEND_SRCS}) - list(APPEND COMPILER_SRCS ${RELAY_IR_SRCS}) - list(APPEND COMPILER_SRCS ${RELAY_QNN_SRCS}) - file(GLOB DATATYPE_SRCS ${TVM_SRC}/src/target/datatype/*.cc) - list(APPEND COMPILER_SRCS ${DATATYPE_SRCS}) - list(APPEND COMPILER_SRCS ${TVM_SRC}/src/target/opt/build_metal_off.cc) - list(APPEND COMPILER_SRCS ${TVM_SRC}/src/target/opt/build_sdaccel_off.cc) - list(APPEND COMPILER_SRCS ${TVM_SRC}/src/target/opt/build_aocl_off.cc) - list(APPEND COMPILER_SRCS ${TVM_SRC}/src/target/opt/build_opencl_off.cc) - list(APPEND COMPILER_SRCS ${TVM_SRC}/src/runtime/container.cc) - list(APPEND DLR_SRC ${COMPILER_SRCS}) set(USE_TENSORRT OFF) endif() if(WITH_HEXAGON) diff --git a/include/dlr.h b/include/dlr.h index 97dcfc930..ea63f5a29 100644 --- a/include/dlr.h +++ b/include/dlr.h @@ -18,7 +18,7 @@ extern "C" { // Open extern "C" block /*! \brief major version */ #define DLR_MAJOR 1 /*! \brief minor version */ -#define DLR_MINOR 6 +#define DLR_MINOR 7 /*! \brief patch version */ #define DLR_PATCH 0 /*! \brief DLR version */ diff --git a/python/dlr/metadata.py b/python/dlr/metadata.py index 973cea361..e2abf8bce 100644 --- a/python/dlr/metadata.py +++ b/python/dlr/metadata.py @@ -1,3 +1,3 @@ NAME = ['DLRModel'] -VERSION = "1.6.0" \ No newline at end of file +VERSION = "1.7.0" \ No newline at end of file diff --git a/src/dlr_relayvm.cc b/src/dlr_relayvm.cc index f2c21cf1a..308a0f38c 100644 --- a/src/dlr_relayvm.cc +++ b/src/dlr_relayvm.cc @@ -86,8 +86,16 @@ void RelayVMModel::SetupVMModule(const std::vector& model_elems) { vm_module_ = std::make_shared(tvm::runtime::Module(vm)); tvm::runtime::PackedFunc init = vm_module_->GetFunction("init"); - init(static_cast(ctx_.device_type), ctx_.device_id, - static_cast(tvm::runtime::vm::AllocatorType::kPooled)); + if (ctx_.device_type == DLDeviceType::kDLCPU) { + init(static_cast(ctx_.device_type), ctx_.device_id, + static_cast(tvm::runtime::vm::AllocatorType::kPooled)); + } else { + // CPU context also must be initialized because input/output data comes from CPU. + init(static_cast(ctx_.device_type), ctx_.device_id, + static_cast(tvm::runtime::vm::AllocatorType::kPooled), + static_cast(DLDeviceType::kDLCPU), 0, + static_cast(tvm::runtime::vm::AllocatorType::kPooled)); + } } void RelayVMModel::FetchInputNodesData() { @@ -268,7 +276,7 @@ void RelayVMModel::SetInput(const char* name, const int64_t* shape, const void* DLDataType dtype = GetInputDLDataType(index); DLTensor input_tensor; input_tensor.data = const_cast(input); - input_tensor.ctx = ctx_; + input_tensor.ctx = DLContext{DLDeviceType::kDLCPU, 0}; input_tensor.ndim = dim; input_tensor.shape = const_cast(shape); input_tensor.strides = nullptr; @@ -357,7 +365,7 @@ void RelayVMModel::GetOutput(int index, void* output) { } DLTensor output_tensor; output_tensor.data = output; - output_tensor.ctx = ctx_; + output_tensor.ctx = DLContext{DLDeviceType::kDLCPU, 0}; output_tensor.ndim = out_array->ndim; output_tensor.dtype = out_array->dtype; output_tensor.shape = out_array->shape; diff --git a/src/dlr_tvm.cc b/src/dlr_tvm.cc index 2dbb5c588..b9c4b7453 100644 --- a/src/dlr_tvm.cc +++ b/src/dlr_tvm.cc @@ -97,7 +97,7 @@ void TVMModel::SetupTVMModule(const std::vector& model_elems) { module = tvm::runtime::Module::LoadFromFile(model_lib_path); tvm_graph_runtime_ = tvm::runtime::make_object(); - tvm_graph_runtime_->Init(graph_str, module, {ctx_}); + tvm_graph_runtime_->Init(graph_str, module, {ctx_}, nullptr); dmlc::MemoryFixedSizeStream strm(const_cast(params_data), params_size); tvm_graph_runtime_->LoadParams(&strm); diff --git a/version.json b/version.json deleted file mode 100644 index fb9f5a5a0..000000000 --- a/version.json +++ /dev/null @@ -1,7 +0,0 @@ -{ - "dlc_version": "1.6.0", - "commit_ids": { - "neo-ai/tvm": "adb14fd3fb035436971ab0081dfaf1fb813e0f44", - "neo-ai/treelite": "38964865d624048d1a432af2763ee1dcdbe3ce5d" - } -}