-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[POC] [Core][NPU][GPU] Weights sharing between GPU and NPU #36941
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
Open
sivanov-work
wants to merge
1
commit into
openvinotoolkit:master
Choose a base branch
from
sivanov-work:npuw_shared_weights
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+788
−2
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
src/inference/dev_api/openvino/runtime/shared_context_buffer_descriptor.hpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| // Copyright (C) 2026 Intel Corporation | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <map> | ||
| #include <memory> | ||
|
|
||
| #include "openvino/runtime/aligned_buffer.hpp" | ||
| #include "openvino/runtime/iremote_context.hpp" | ||
| #include "openvino/runtime/iremote_tensor.hpp" | ||
| #include "openvino/runtime/so_ptr.hpp" | ||
|
|
||
| namespace ov { | ||
|
|
||
| /// \brief Buffer descriptor that carries the set of remote contexts which co-own | ||
| /// (or should receive) the underlying allocation. | ||
| /// | ||
| /// Extends the base IBufferDescriptor interface so that consumers can | ||
| /// retrieve the associated remote contexts via get_remote_contexts(). | ||
|
|
||
| class OPENVINO_RUNTIME_API SharedContextBufferDescriptor : public ov::IBufferDescriptor { | ||
| public: | ||
| struct RemoteContextPtrLess { | ||
| bool operator()(const ov::SoPtr<ov::IRemoteContext>& lhs, | ||
| const ov::SoPtr<ov::IRemoteContext>& rhs) const noexcept { | ||
| return std::less<const ov::IRemoteContext*>{}(lhs._ptr.get(), rhs._ptr.get()); | ||
| } | ||
| }; | ||
|
|
||
| using RemoteContextsMap = std::map<ov::SoPtr<ov::IRemoteContext>, | ||
| ov::SoPtr<ov::IRemoteTensor>, | ||
| RemoteContextPtrLess>; | ||
|
|
||
| SharedContextBufferDescriptor(size_t id, | ||
| size_t offset, | ||
| size_t real_buffer_size, | ||
| const std::shared_ptr<ov::AlignedBuffer>& source_buffer, | ||
| RemoteContextsMap remote_contexts); | ||
|
|
||
| size_t get_id() const override; | ||
| size_t get_offset() const override; | ||
| size_t get_real_buffer_size() const; | ||
| std::shared_ptr<ov::AlignedBuffer> get_source_buffer() const override; | ||
|
|
||
| const RemoteContextsMap& get_remote_contexts() const; | ||
|
|
||
| ~SharedContextBufferDescriptor() override; | ||
|
|
||
| private: | ||
| size_t m_id = 0; | ||
| size_t m_offset = 0; | ||
| size_t m_real_buffer_size = 0; | ||
| std::weak_ptr<ov::AlignedBuffer> m_source_buffer; | ||
| RemoteContextsMap m_remote_contexts; | ||
| }; | ||
|
|
||
| } // namespace ov |
45 changes: 45 additions & 0 deletions
45
src/inference/src/dev/shared_context_buffer_descriptor.cpp
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| // Copyright (C) 2026 Intel Corporation | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| #include "openvino/runtime/shared_context_buffer_descriptor.hpp" | ||
|
|
||
| #include <utility> | ||
|
|
||
| namespace ov { | ||
|
|
||
| SharedContextBufferDescriptor::SharedContextBufferDescriptor( | ||
| size_t id, | ||
| size_t offset, | ||
| size_t real_buffer_size, | ||
| const std::shared_ptr<ov::AlignedBuffer>& source_buffer, | ||
| RemoteContextsMap remote_contexts) | ||
| : m_id(id), | ||
| m_offset(offset), | ||
| m_real_buffer_size(real_buffer_size), | ||
| m_source_buffer(source_buffer), | ||
| m_remote_contexts(std::move(remote_contexts)) {} | ||
|
|
||
| SharedContextBufferDescriptor::~SharedContextBufferDescriptor() = default; | ||
|
|
||
| size_t SharedContextBufferDescriptor::get_id() const { | ||
| return m_id; | ||
| } | ||
|
|
||
| size_t SharedContextBufferDescriptor::get_offset() const { | ||
| return m_offset; | ||
| } | ||
|
|
||
| size_t SharedContextBufferDescriptor::get_real_buffer_size() const { | ||
| return m_real_buffer_size; | ||
| } | ||
|
|
||
| std::shared_ptr<ov::AlignedBuffer> SharedContextBufferDescriptor::get_source_buffer() const { | ||
| return m_source_buffer.lock(); | ||
| } | ||
|
|
||
| const SharedContextBufferDescriptor::RemoteContextsMap& SharedContextBufferDescriptor::get_remote_contexts() const { | ||
| return m_remote_contexts; | ||
| } | ||
|
|
||
| } // namespace ov |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@michal-miotk Do you know what might be the right way to check for GPU device?
My concerns are:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.