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

[NPU] Use zero tensor to get correct data #27980

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

pereanub
Copy link
Contributor

@pereanub pereanub commented Dec 9, 2024

Details:

  • Can not deallocate and re-allocate a newer memory for tensor if update mutable command list is not supported. Newer memory should be updated in the graph and this can be done only using the updating command list feature
  • In order to check if the memory was or wasn't re-allocated we are checking the unique ID provided by the driver when memory is created

Tickets:

  • E#134453

@github-actions github-actions bot added the category: NPU OpenVINO NPU plugin label Dec 9, 2024
@pereanub pereanub changed the title Use zero tensor to get correct data [NPU] Use zero tensor to get correct data Dec 9, 2024
@pereanub pereanub changed the title [NPU] Use zero tensor to get correct data [DO NOT MERGE][NPU] Use zero tensor to get correct data Dec 10, 2024
@pereanub pereanub marked this pull request as ready for review December 10, 2024 13:37
@pereanub pereanub requested review from a team as code owners December 10, 2024 13:37
@pereanub pereanub force-pushed the use_correct_tensor branch 11 times, most recently from c718ff5 to b1afd2c Compare December 16, 2024 14:55
@pereanub pereanub changed the title [DO NOT MERGE][NPU] Use zero tensor to get correct data [NPU] Use zero tensor to get correct data Dec 18, 2024
Copy link
Contributor

@razvanapetroaie razvanapetroaie left a comment

Choose a reason for hiding this comment

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

Halfway through, nothing major so far.

Copy link
Contributor

@razvanapetroaie razvanapetroaie left a comment

Choose a reason for hiding this comment

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

@MirceaDan99 Please let us know if you have anything before merging this.

src/plugins/intel_npu/src/backend/src/zero_pipeline.cpp Outdated Show resolved Hide resolved
continue;
}

if (std::dynamic_pointer_cast<ZeroRemoteTensor>(levelZeroTensor.at(SINGLE_TENSOR)) != nullptr) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since these three ifs share the same body, you may consider writing them in a more compact manner. That is: if (condition1 || condition2 || condition3) then common_body.

I've also noticed you're using std::dynamic_pointer_cast<ZeroRemoteTensor> quite often for determining whether the tensor is remote or not. You may consider creating a static method inside ZeroRemoteTensor, perhaps called is_remote_tensor, which does this check.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure about the second part of the comment. We still need to do the cast, correct? Since it is an ITensor as default. Can I call methods from the derivate class in this case?

Copy link
Contributor

Choose a reason for hiding this comment

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

Was thinking you could do something like:

class ZeroRemoteTensor {
public:
static bool is_remote_tensor(const std::shared_ptr<ov::ITensor>& tensor) {
    return std::dynamic_pointer_cast<ZeroRemoteTensor>(tensor) != nullptr;
}
};

And call it like: ZeroRemoteTensor::is_remote_tensor(tensor). So I guess in this case you would just place the helper function inside the ZeroRemoteTensor "namespace" practically. Not sure if this is the best approach or the best place for the helper function, the suggestion is mainly about defining a helper for this wherever you think it belongs best.

}

const auto inputDescriptor = _metadata.inputs.at(inputIndex);
if (inputDescriptor.isShapeTensor || inputDescriptor.isStateInput) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We sure we should skip state tensors? Just asking if you've considered this case hard enough, I haven't checked this yet. The tensor can be retrieved via SyncInferRequest::query_state -> get_state.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure yet how this is supposed to work with state tensors.

@pereanub pereanub force-pushed the use_correct_tensor branch 6 times, most recently from f505588 to 1b6d092 Compare January 8, 2025 10:25
@pereanub pereanub force-pushed the use_correct_tensor branch from 1b6d092 to 71035d6 Compare January 8, 2025 10:39
@pereanub pereanub force-pushed the use_correct_tensor branch from 71035d6 to ae58e16 Compare January 8, 2025 11:26
@pereanub pereanub force-pushed the use_correct_tensor branch from ae58e16 to bd6c07b Compare January 8, 2025 11:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: NPU OpenVINO NPU plugin
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants