-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Reduce IR Constant Memory Retention #35457
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
barnasm1
wants to merge
55
commits into
openvinotoolkit:master
Choose a base branch
from
barnasm1:separate_buffer_poc
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.
Open
Changes from all commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
a17e69d
Implement WeightsProvider and FileWeightsProvider for flexible weight…
barnasm1 a898eb6
Merge branch 'master' into separate_buffer_poc
barnasm1 b1e8e47
fix win build
barnasm1 8b75d6f
fix win buildweight provider + prevend double budder alocatino
barnasm1 cdc4489
code format
barnasm1 a58a3f4
Merge branch 'master' into separate_buffer_poc
barnasm1 bb4e162
Merge branch 'master' into separate_buffer_poc
barnasm1 34c9047
do not use env flag
barnasm1 4d26e5d
weights loading logic if no enable mmap
barnasm1 f64c4e3
Add assertion to check if weights file can be opened in FileWeightsPr…
barnasm1 a313c19
Add FileRegionBuffer class and enhance FileWeightsProvider with sourc…
barnasm1 f1bbb4e
Merge branch 'master' into separate_buffer_poc
barnasm1 434b15f
Fix formatting
barnasm1 0b1bb5a
Remove const qualifier from load_region
barnasm1 8fac1d4
Remove unnecessary null check in BufferWeightsProvider::size()
barnasm1 d48f7d6
Merge branch 'master' into separate_buffer_poc
barnasm1 5edf87c
skip ate flag
barnasm1 22f6492
move WeightsProvider to separate file
barnasm1 3febebc
use ov util to file size
barnasm1 b9374f5
remove assertion for empty weights provider
barnasm1 a0258c8
refactor: remove load_weights_region and get_available_weights_size m…
barnasm1 f9acab0
use simpler hash function
barnasm1 df0ae2a
documentation for WeightsProvider interface
barnasm1 7776a19
refactor: remove FileRegionBuffer class and simplify load_region meth…
barnasm1 8b63fd4
Merge branch 'master' into separate_buffer_poc
barnasm1 1be1fb9
Revert "refactor: remove FileRegionBuffer class and simplify load_reg…
barnasm1 4133e84
Merge branch 'master' into separate_buffer_poc
barnasm1 e89b25d
add assertions for weights provider in XmlDeserializer. fix test: mod…
barnasm1 cb9a012
rename load_region to make_region
barnasm1 36322dd
add comment to m_loaded_weights_regions key
barnasm1 22b5f2a
simplify assert
barnasm1 c94a6f9
rename load_region to make_region - fix build
barnasm1 67b68a2
revert weight size checks
barnasm1 7e06fcc
update weight assertion message and add check for weights size
barnasm1 522ebf3
Merge branch 'master' into separate_buffer_poc
barnasm1 a77e0c0
Fix error message formatting in weight file assertions
barnasm1 ab6624c
use lazy_buffer
barnasm1 5039491
Merge branch 'master' into separate_buffer_poc
mlukasze 979b018
FileWeightsProvider fix CI
barnasm1 d8dc9a2
Merge branch 'master' into separate_buffer_poc
barnasm1 e3af9ec
Merge branch 'master' into separate_buffer_poc
barnasm1 de95e5f
init all or none
barnasm1 ec779b3
avoid double check
barnasm1 afb3465
Refactor XmlDeserializer to use WeightsProvider for weight management
barnasm1 671dc06
Refactor FileWeightsProvider to remove FileRegionBuffer and optimize …
barnasm1 a9f499e
Add weights_provider source and header to xml_util CMakeLists
barnasm1 1ae4bb5
Refactor InputModelIRImpl constructor to initialize weights_provider …
barnasm1 90e5ae7
Refactor InputModelIRImpl to remove weights_path parameter and utiliz…
barnasm1 d8cb394
Merge branch 'master' into separate_buffer_poc
barnasm1 3e5501d
Merge branch 'master' into separate_buffer_poc
barnasm1 d93206a
Refactor XmlDeserializer to use const reference for weights_provider
barnasm1 0190e63
Change loaded_weights_regions from shared_ptr to weak_ptr
barnasm1 6c88331
Refactor parse_pre_process to use shared_ptr for Constant creation
barnasm1 c5c33d8
Disable mmap-related tests until FileWeightsProvider uses LazyBuffer
barnasm1 0732d5a
Merge branch 'master' into separate_buffer_poc
mlukasze 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
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
128 changes: 128 additions & 0 deletions
128
src/core/xml_util/include/openvino/xml_util/weights_provider.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,128 @@ | ||
| // Copyright (C) 2018-2026 Intel Corporation | ||
| // SPDX-License-Identifier: Apache-2.0 | ||
| // | ||
|
|
||
| #pragma once | ||
|
|
||
| #include <filesystem> | ||
| #include <map> | ||
| #include <memory> | ||
|
|
||
| namespace ov { | ||
| class AlignedBuffer; | ||
| } // namespace ov | ||
|
|
||
| namespace ov::util { | ||
|
|
||
| /** | ||
| * @brief Interface for loading weight data regions from an underlying storage. | ||
| * | ||
| * Implementations may serve weights either from an in-memory buffer or from a | ||
| * file-backed source. | ||
| */ | ||
| class WeightsProvider { | ||
| public: | ||
| virtual ~WeightsProvider() = default; | ||
|
|
||
| /** | ||
| * @brief Make a contiguous region of weights. | ||
| * | ||
| * @param offset Byte offset from the beginning of the weights source. | ||
| * @param size Number of bytes to load. | ||
| * @return Buffer containing the requested weights region. | ||
| */ | ||
| virtual std::shared_ptr<ov::AlignedBuffer> make_region(size_t offset, size_t size) = 0; | ||
|
|
||
| /** | ||
| * @brief Returns the total size of the weights source in bytes. | ||
| * | ||
| * @return Size of the underlying weights source. | ||
| */ | ||
| virtual size_t size() const = 0; | ||
|
|
||
| /** | ||
| * @brief Returns the path to the weights source when the provider is file-backed. | ||
| * | ||
| * @return Path to the weights source, or an empty path if the provider is not file-backed. | ||
| */ | ||
| virtual std::filesystem::path path() const; | ||
|
praasz marked this conversation as resolved.
|
||
| }; | ||
|
|
||
| /** | ||
| * @brief Weights provider implementation backed by an already allocated buffer. | ||
| */ | ||
| class BufferWeightsProvider : public WeightsProvider { | ||
| public: | ||
| /** | ||
| * @brief Constructs a weights provider over an existing buffer. | ||
| * | ||
| * @param weights Buffer containing the full weights blob. | ||
| */ | ||
| explicit BufferWeightsProvider(std::shared_ptr<ov::AlignedBuffer> weights); | ||
|
|
||
| /** | ||
| * @brief Returns a view of the requested region from the backing buffer. | ||
| * | ||
| * @param offset Byte offset from the beginning of the weights buffer. | ||
| * @param size Number of bytes to expose. | ||
| * @return Buffer referencing the requested region. | ||
| */ | ||
| std::shared_ptr<ov::AlignedBuffer> make_region(size_t offset, size_t size) override; | ||
|
|
||
| /** | ||
| * @brief Returns the total size of the backing weights buffer in bytes. | ||
| * | ||
| * @return Size of the underlying buffer. | ||
| */ | ||
| size_t size() const override; | ||
|
|
||
| private: | ||
| std::shared_ptr<ov::AlignedBuffer> m_weights; | ||
| }; | ||
|
|
||
| /** | ||
| * @brief Weights provider implementation backed by a weights file on disk. | ||
| */ | ||
| class FileWeightsProvider : public WeightsProvider { | ||
| public: | ||
| /** | ||
| * @brief Constructs a weights provider for the specified file. | ||
| * | ||
| * @param weights_path Path to the weights file. | ||
| */ | ||
| explicit FileWeightsProvider(std::filesystem::path weights_path); | ||
|
|
||
| /** | ||
| * @brief Loads the requested region from the weights file. | ||
| * | ||
| * Implementations may cache previously loaded regions. | ||
| * | ||
| * @param offset Byte offset from the beginning of the weights file. | ||
| * @param size Number of bytes to load. | ||
| * @return Buffer containing the requested file region. | ||
| */ | ||
| std::shared_ptr<ov::AlignedBuffer> make_region(size_t offset, size_t size) override; | ||
|
|
||
| /** | ||
| * @brief Returns the total size of the weights file in bytes. | ||
| * | ||
| * @return Size of the file-backed weights source. | ||
| */ | ||
| size_t size() const override; | ||
|
|
||
| /** | ||
| * @brief Returns the path to the backing weights file. | ||
| * | ||
| * @return Path to the backing weights file. | ||
| */ | ||
| std::filesystem::path path() const override; | ||
|
|
||
| private: | ||
| using WeightsRegionKey = std::pair<size_t, size_t>; | ||
|
praasz marked this conversation as resolved.
|
||
|
|
||
| std::filesystem::path m_weights_path{}; | ||
| size_t m_weights_size{}; | ||
| // Cache of previously loaded weights regions, keyed by (offset, size) of the region in the weights file. | ||
| std::map<WeightsRegionKey, std::weak_ptr<ov::AlignedBuffer>> m_loaded_weights_regions; | ||
| }; | ||
| } // namespace ov::util | ||
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.
Uh oh!
There was an error while loading. Please reload this page.