From a3f05da33875d4e8383c0b91d82ecd338842ca1e Mon Sep 17 00:00:00 2001 From: Yi Zhang Date: Fri, 13 May 2022 02:27:36 +0800 Subject: [PATCH] Revert "[TVM EP] update set input to remove excess copying inside TVM (#11247)" (#11504) This reverts commit 5ae461ec0a4c934b44b6939cc2332b9dbd4f2db2. --- cgmanifests/cgmanifest.json | 2 +- cmake/external/tvm.cmake | 2 +- onnxruntime/core/providers/tvm/tvm_allocator.cc | 4 ++-- onnxruntime/core/providers/tvm/tvm_api.cc | 16 ++++------------ 4 files changed, 8 insertions(+), 16 deletions(-) diff --git a/cgmanifests/cgmanifest.json b/cgmanifests/cgmanifest.json index e07f71574c..d7d1f380e5 100644 --- a/cgmanifests/cgmanifest.json +++ b/cgmanifests/cgmanifest.json @@ -46,7 +46,7 @@ "component": { "type": "git", "git": { - "commitHash": "fafabc96c1ba1a5f987c2402fcc2ce4d1bad5cc8", + "commitHash": "ffd5f70370642c909222f9a4cae8400023dacbdc", "repositoryUrl": "https://github.com/apache/tvm.git" }, "comments": "needed for TVM EP" diff --git a/cmake/external/tvm.cmake b/cmake/external/tvm.cmake index 82d7114a66..3f425a0938 100644 --- a/cmake/external/tvm.cmake +++ b/cmake/external/tvm.cmake @@ -4,7 +4,7 @@ if (onnxruntime_USE_TVM) FetchContent_Declare( tvm GIT_REPOSITORY https://github.com/apache/tvm.git - GIT_TAG fafabc96c1ba1a5f987c2402fcc2ce4d1bad5cc8 + GIT_TAG ffd5f70370642c909222f9a4cae8400023dacbdc ) FetchContent_GetProperties(tvm) diff --git a/onnxruntime/core/providers/tvm/tvm_allocator.cc b/onnxruntime/core/providers/tvm/tvm_allocator.cc index 8793676421..ef06e1f59a 100644 --- a/onnxruntime/core/providers/tvm/tvm_allocator.cc +++ b/onnxruntime/core/providers/tvm/tvm_allocator.cc @@ -14,7 +14,7 @@ void* TVMAllocator::Alloc(size_t size) { void* p = nullptr; if (size > 0) { DLDataType dl_type{kDLInt, 8, 1}; - int err = TVMDeviceAllocDataSpace(ctx, size, TVM_ALLOC_ALIGN, dl_type, (void**)&p); + int err = TVMDeviceAllocDataSpace(ctx, size, 128, dl_type, (void**)&p); CHECK_EQ(err, 0); return p; } @@ -22,7 +22,7 @@ void* TVMAllocator::Alloc(size_t size) { } void TVMAllocator::Free(void* p) { - TVMDeviceFreeDataSpace(ctx, p); + TVMDeviceFreeDataSpace(ctx, p); } } // namespace tvm diff --git a/onnxruntime/core/providers/tvm/tvm_api.cc b/onnxruntime/core/providers/tvm/tvm_api.cc index 0c5e07b302..ff61c6c43d 100644 --- a/onnxruntime/core/providers/tvm/tvm_api.cc +++ b/onnxruntime/core/providers/tvm/tvm_api.cc @@ -70,19 +70,11 @@ void TVM_VM_SetInputs(TvmModule& mod, std::vector& inds, std::vector& inputs) { - size_t num_total_args = inputs.size() + 1; - std::vector tvm_values(num_total_args); - std::vector tvm_type_codes(num_total_args); - ::tvm::runtime::TVMArgsSetter setter(tvm_values.data(), tvm_type_codes.data()); - const std::string func_name = "main"; - setter(0, func_name.c_str()); - for (size_t k = 0; k < num_total_args - 1; ++k) { - setter(inds[k]+1, &inputs[k]); + TvmPackedFunc set_input = mod.GetFunction("set_one_input", false); + for (size_t i = 0; i < inds.size(); ++i) + { + set_input("main", inds[i], &inputs[i]); } - - TvmPackedFunc set_input = mod.GetFunction("set_input", false); - ::tvm::runtime::TVMRetValue rv; - set_input.CallPacked(::tvm::runtime::TVMArgs(tvm_values.data(), tvm_type_codes.data(), num_total_args), &rv); } void TVMGetOutputs(TvmModule& mod,