Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: caching lookup to behave correctly when inputs/output mapping #450

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ericcraw
Copy link

@ericcraw ericcraw commented Sep 24, 2024

Description

  1. changing the emplace to [] that does have a difference, emplace will only create a new entry if it doesn't already exist in the map
  2. change the logic of the caching lookup to key off of input/output names instead of ort raw ptrs.
  3. changes OV tensor creation for CPU allocated input/output ORT tensors. The CPU allocated input/output tensor path was re-allocating OV tensors based on the ORT input/output tensors. So we'd get 2 copies: ORT input/output tensor -> OV tensor (OVEP) -> NPU Tensor (NPU plugin).

Motivation and Context

@ericcraw ericcraw changed the title [DML EP] Update DML to 1.15.1 (#21695) fix: caching lookup to behave correctly when inputs/output mapping ar… Sep 24, 2024
@ericcraw ericcraw changed the title fix: caching lookup to behave correctly when inputs/output mapping ar… fix: caching lookup to behave correctly when inputs/output mapping Sep 24, 2024
} else {
// Does this make sense for both types of allocators?
ort_tensor_key_t ort_tensor_key{input_name};
auto it = ort_ov_tensor_map.find(ort_tensor_key);

Choose a reason for hiding this comment

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

when are we first inserting the values in the map ? if (it != ort_ov_tensor_map.end() || it->second.ort_ptr != tensor.GetTensorRawData())

// Does this make sense for both types of allocators?
ort_tensor_key_t ort_tensor_key{input_name};
auto it = ort_ov_tensor_map.find(ort_tensor_key);
if (it != ort_ov_tensor_map.end() || it->second.ort_ptr != tensor.GetTensorRawData()) {

Choose a reason for hiding this comment

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

the first condition will always be false

ov_tensor_data.tensor_ptr = std::make_shared<ov::Tensor>(input.get_element_type(), input.get_shape(),
(void*)tensor.GetTensorRawData());
ov_tensor_data.ort_ptr = tensor.GetTensorRawData();
ort_ov_tensor_map[ort_tensor_key] = ov_tensor_data;

Choose a reason for hiding this comment

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

do we even need to specify the ORT_NPU_ALLOCATOR anymore

@preetha-intel preetha-intel marked this pull request as draft October 1, 2024 13:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants