forked from openvinotoolkit/openvino
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[intel-npu] Support new internal
cached_model_buffer
config for mem…
…ory mapped cached blobs (openvinotoolkit#27822) ### Details: - *Based on <s>new `import_model` API from PR openvinotoolkit#27644</s> new plugins property to pass mmap buffer from PR openvinotoolkit#27981* - *Added `BlobContainer` class for `IGraph` objects that may derive with `BlobContainerAlignedBuffer` for the new `import_model` API and `BlobContainerVector` for the old one* - *Refactored `getGraphHandle` function to allow passing `const uint8_t` and `size_t` params instead of `std::vector<uint8_t>* ### Tickets: - *157192* --------- Signed-off-by: Alexandru Enache <[email protected]> Co-authored-by: Alexandru Enache <[email protected]> Co-authored-by: Oleg Pipikin <[email protected]>
- Loading branch information
Showing
16 changed files
with
161 additions
and
51 deletions.
There are no files selected for viewing
81 changes: 81 additions & 0 deletions
81
src/plugins/intel_npu/src/common/include/intel_npu/common/blob_container.hpp
This file contains 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,81 @@ | ||
// Copyright (C) 2018-2025 Intel Corporation | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
|
||
#pragma once | ||
|
||
#include <memory> | ||
#include <vector> | ||
|
||
#include "openvino/runtime/shared_buffer.hpp" | ||
|
||
namespace intel_npu { | ||
|
||
class BlobContainer { | ||
public: | ||
/** | ||
* @brief Returns the address at the beginning of the blob. | ||
*/ | ||
virtual const void* get_ptr() const = 0; | ||
|
||
/** | ||
* @brief Size of the blob. | ||
*/ | ||
virtual size_t size() const = 0; | ||
|
||
/** | ||
* @brief Returns true if the blob can be deallocated from memory, false otherwise. | ||
*/ | ||
virtual bool release_from_memory() = 0; | ||
|
||
virtual ~BlobContainer() = default; | ||
}; | ||
|
||
class BlobContainerVector : public BlobContainer { | ||
public: | ||
BlobContainerVector(std::vector<uint8_t> blob) : _blob(std::move(blob)) {} | ||
|
||
const void* get_ptr() const override { | ||
return reinterpret_cast<const void*>(_blob.data()); | ||
} | ||
|
||
size_t size() const override { | ||
return _blob.size(); | ||
} | ||
|
||
bool release_from_memory() override { | ||
_blob.clear(); | ||
_blob.shrink_to_fit(); | ||
return true; | ||
} | ||
|
||
private: | ||
std::vector<uint8_t> _blob; | ||
}; | ||
|
||
class BlobContainerAlignedBuffer : public BlobContainer { | ||
public: | ||
BlobContainerAlignedBuffer(const std::shared_ptr<ov::AlignedBuffer>& blobSO, size_t ovHeaderOffset, uint64_t size) | ||
: _size(size), | ||
_ovHeaderOffset(ovHeaderOffset), | ||
_blobSO(blobSO) {} | ||
|
||
const void* get_ptr() const override { | ||
return _blobSO->get_ptr(_ovHeaderOffset); | ||
} | ||
|
||
size_t size() const override { | ||
return _size; | ||
} | ||
|
||
bool release_from_memory() override { | ||
return false; | ||
} | ||
|
||
private: | ||
uint64_t _size; | ||
size_t _ovHeaderOffset; | ||
std::shared_ptr<ov::AlignedBuffer> _blobSO; | ||
}; | ||
|
||
} // namespace intel_npu |
This file contains 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 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 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 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 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 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 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 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 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 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 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 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 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 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.