Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 4 additions & 8 deletions onnxruntime/core/providers/openvino/backends/basic_backend.cc
Original file line number Diff line number Diff line change
Expand Up @@ -306,9 +306,7 @@ void BasicBackend::StartAsyncInference(Ort::KernelContext& context, OVInferReque
auto allocator_name = tensor.GetTensorMemoryInfo().GetAllocatorName();
ov_tensor_data_t ov_tensor_key;
ort_tensor_key_t ort_tensor_key{tensor.GetTensorRawData(), allocator_name};
if (const auto& it = ort_ov_tensor_map.find(ort_tensor_key); it != ort_ov_tensor_map.end()) {
ov_tensor_key = it->second;
} else {
{
// Does this make sense for both types of allocators?
auto input = graph_input_info.at(input_idx);
if (allocator_name == OpenVINO_RT_NPU) {
Expand All @@ -319,7 +317,7 @@ void BasicBackend::StartAsyncInference(Ort::KernelContext& context, OVInferReque
ov_tensor_key.copy_needed = true;
ov_tensor_key.tensor_ptr = std::make_shared<ov::Tensor>(input.get_element_type(), input.get_shape());
}
ort_ov_tensor_map.emplace(ort_tensor_key, ov_tensor_key);
ort_ov_tensor_map[ort_tensor_key] = ov_tensor_key;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should not be initialized if not used


if (ov_tensor_key.copy_needed) {
const char* ort_tensor_data = tensor.GetTensorData<char>();
Expand Down Expand Up @@ -366,9 +364,7 @@ void BasicBackend::StartAsyncInference(Ort::KernelContext& context, OVInferReque

ov_tensor_data_t ov_tensor_data;
ort_tensor_key_t ort_tensor_key{tensor.GetTensorRawData(), allocator_name};
if (const auto& it = ort_ov_tensor_map.find(ort_tensor_key); it != ort_ov_tensor_map.end()) {
ov_tensor_data = it->second;
} else {
{
auto output = graph_output_info.at(output_idx);
if (allocator_name == OpenVINO_RT_NPU) {
ov_tensor_data.copy_needed = false;
Expand All @@ -378,7 +374,7 @@ void BasicBackend::StartAsyncInference(Ort::KernelContext& context, OVInferReque
ov_tensor_data.copy_needed = true;
ov_tensor_data.tensor_ptr = std::make_shared<ov::Tensor>(output.get_element_type(), output.get_shape());
}
ort_ov_tensor_map.emplace(ort_tensor_key, ov_tensor_data);
ort_ov_tensor_map[ort_tensor_key] = ov_tensor_data;

try {
infer_request->SetTensor(output_name, ov_tensor_data.tensor_ptr);
Expand Down