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.
- Loading branch information
1 parent
60a36c4
commit b9f9c3d
Showing
11 changed files
with
88 additions
and
86 deletions.
There are no files selected for viewing
70 changes: 70 additions & 0 deletions
70
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,70 @@ | ||
// Copyright (C) 2018-2024 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: | ||
virtual void* get_ptr() = 0; | ||
|
||
virtual size_t size() const = 0; | ||
|
||
virtual bool release_from_memory() = 0; | ||
|
||
virtual ~BlobContainer() = default; | ||
}; | ||
|
||
class BlobContainerVector : public BlobContainer { | ||
public: | ||
BlobContainerVector(std::vector<uint8_t> blob) : _ownershipBlob(std::move(blob)) {} | ||
|
||
void* get_ptr() override { | ||
return reinterpret_cast<void*>(_ownershipBlob.data()); | ||
} | ||
|
||
size_t size() const override { | ||
return _ownershipBlob.size(); | ||
} | ||
|
||
bool release_from_memory() override { | ||
_ownershipBlob.clear(); | ||
_ownershipBlob.shrink_to_fit(); | ||
return true; | ||
} | ||
|
||
private: | ||
std::vector<uint8_t> _ownershipBlob; | ||
}; | ||
|
||
class BlobContainerAlignedBuffer : public BlobContainer { | ||
public: | ||
BlobContainerAlignedBuffer(const std::shared_ptr<ov::AlignedBuffer>& blobSO, size_t offset) | ||
: _ownershipBlob(blobSO), | ||
_offset(offset) {} | ||
|
||
void* get_ptr() override { | ||
return _ownershipBlob->get_ptr(_offset); | ||
} | ||
|
||
size_t size() const override { | ||
return _ownershipBlob->size(); | ||
} | ||
|
||
bool release_from_memory() override { | ||
return false; | ||
} | ||
|
||
private: | ||
std::shared_ptr<ov::AlignedBuffer> _ownershipBlob; | ||
size_t _offset; | ||
}; | ||
|
||
} // 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