[TVM EP] update set input method for VirtualMachine (#11674)

* update TVM

* get alignment constant from TVM

* update TVM_VM_SetInputs to upstream with TVM API

* fix CI issue: update TVM EP dependencies

* add sudo

* revert changes needed to install missing package

* add package for TVM EP CI

Co-authored-by: Valery Chernov <valery.chernov@deelvin.com>
Co-authored-by: KJlaccHoeUM9l <wotpricol@mail.ru>
This commit is contained in:
Valery Chernov 2022-06-04 10:31:01 +03:00 committed by GitHub
parent d5e34acb82
commit 4296968f20
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 20 additions and 8 deletions

View file

@ -8,7 +8,7 @@
"repositoryUrl": "https://github.com/abseil/abseil-cpp.git"
}
}
},
},
{
"component": {
"Type": "maven",
@ -46,7 +46,7 @@
"component": {
"type": "git",
"git": {
"commitHash": "ffd5f70370642c909222f9a4cae8400023dacbdc",
"commitHash": "bc492acd7677dd7875b14f9ee46beef658955441",
"repositoryUrl": "https://github.com/apache/tvm.git"
},
"comments": "needed for TVM EP"

View file

@ -4,7 +4,7 @@ if (onnxruntime_USE_TVM)
FetchContent_Declare(
tvm
GIT_REPOSITORY https://github.com/apache/tvm.git
GIT_TAG ffd5f70370642c909222f9a4cae8400023dacbdc
GIT_TAG bc492acd7677dd7875b14f9ee46beef658955441
)
FetchContent_GetProperties(tvm)
@ -33,4 +33,4 @@ if (onnxruntime_USE_NUPHAR)
set(tvm_INCLUDE_DIRS ${tvm_SOURCE_DIR}/include)
endif()
endif()

View file

@ -1,6 +1,8 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
#include <tvm/runtime/device_api.h>
#include "tvm_allocator.h"
#include "core/framework/allocatormgr.h"
#include "core/framework/session_state.h"
@ -14,7 +16,7 @@ void* TVMAllocator::Alloc(size_t size) {
void* p = nullptr;
if (size > 0) {
DLDataType dl_type{kDLInt, 8, 1};
int err = TVMDeviceAllocDataSpace(ctx, size, 128, dl_type, reinterpret_cast<void**>(&p));
int err = TVMDeviceAllocDataSpace(ctx, size, ::tvm::runtime::kAllocAlignment, dl_type, reinterpret_cast<void**>(&p));
CHECK_EQ(err, 0);
return p;
}

View file

@ -193,10 +193,19 @@ void TVM_VM_SetInputs(TvmModule& mod,
std::vector<size_t>& inds,
std::vector<DLTensor>& inputs)
{
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]);
size_t num_total_args = inputs.size() + 1;
std::vector<TVMValue> tvm_values(num_total_args);
std::vector<int> 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_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,

View file

@ -42,6 +42,7 @@ PACKAGE_LIST="autotools-dev \
libssl1.1 \
libkrb5-3 \
libtinfo-dev \
libtinfo5 \
libtool \
openssh-server \
aria2 \