Skip to content

Commit

Permalink
reserve memory for vector of DLTensors
Browse files Browse the repository at this point in the history
  • Loading branch information
Valery Chernov committed Dec 14, 2021
1 parent f037da2 commit 792817b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions onnxruntime/core/providers/stvm/stvm_execution_provider.cc
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,10 @@ class STVMRunner {
common::Status operator()(FunctionState state, const OrtCustomOpApi* api, OrtKernelContext* context) {
Ort::CustomOpApi ort{*api};

std::vector<size_t> inds;
std::vector<DLTensor> dl_tensors_inputs;
size_t num = inputs_info_.size();
std::vector<size_t> inds(num);
std::vector<DLTensor> dl_tensors_inputs(num);
size_t counter = 0u;
for (auto& info : inputs_info_) {
// TODO(vvchernov): decomposition declaration only available with -std=c++1z or -std=gnu++1z
auto& i = info.first;
Expand All @@ -146,8 +148,8 @@ class STVMRunner {
t.data = const_cast<void*>(ort.GetTensorData<void>(input_tensor));
t.ndim = shape.size();
t.shape = shape.data();
dl_tensors_inputs.push_back(t);
inds.push_back(i);
dl_tensors_inputs[counter] = t;
inds[counter++] = i;
}
stvm::TVMSetInputs(*mod_, inds, dl_tensors_inputs);

Expand Down Expand Up @@ -211,7 +213,7 @@ class STVMRunner {

private:
tvm::runtime::Module* mod_;
InputsInfoMap inputs_info_;
InputsInfoMap inputs_info_{};
bool update_output_shapes_ = false;
TVMTensorShapes output_shapes_;
std::vector<DLTensor> tensors_outputs_;
Expand Down

0 comments on commit 792817b

Please sign in to comment.