diff --git a/src/core/dev_api/openvino/runtime/aligned_buffer.hpp b/src/core/dev_api/openvino/runtime/aligned_buffer.hpp index 904e30999d10df..a7cf78ae9ee658 100644 --- a/src/core/dev_api/openvino/runtime/aligned_buffer.hpp +++ b/src/core/dev_api/openvino/runtime/aligned_buffer.hpp @@ -30,14 +30,17 @@ class OPENVINO_API AlignedBuffer { size_t size() const { return m_byte_size; } + void updateOffset(size_t offset) { + m_offset = offset; + } void* get_ptr(size_t offset) const { return m_aligned_buffer + offset; } void* get_ptr() { - return m_aligned_buffer; + return m_aligned_buffer + m_offset; } const void* get_ptr() const { - return m_aligned_buffer; + return m_aligned_buffer + m_offset; } template T* get_ptr() { @@ -61,6 +64,7 @@ class OPENVINO_API AlignedBuffer { char* m_allocated_buffer; char* m_aligned_buffer; size_t m_byte_size; + size_t m_offset = 0; }; template <> diff --git a/src/core/dev_api/openvino/runtime/shared_buffer.hpp b/src/core/dev_api/openvino/runtime/shared_buffer.hpp index 2c784ef6081c35..859675344c98b8 100644 --- a/src/core/dev_api/openvino/runtime/shared_buffer.hpp +++ b/src/core/dev_api/openvino/runtime/shared_buffer.hpp @@ -16,6 +16,7 @@ class SharedBuffer : public ov::AlignedBuffer { m_allocated_buffer = data; m_aligned_buffer = data; m_byte_size = size; + m_offset = 0; } virtual ~SharedBuffer() { @@ -81,6 +82,26 @@ class OwningSharedStreamBuffer : public SharedStreamBuffer { return m_shared_obj; } + std::streamsize xsgetn(char* s, std::streamsize count) override { + auto streamSize = SharedStreamBuffer::xsgetn(s, count); + m_shared_obj->updateOffset(m_offset); + return streamSize; + } + + int_type uflow() override { + auto val = SharedStreamBuffer::uflow(); + m_shared_obj->updateOffset(m_offset); + return val; + } + + pos_type seekoff(off_type off, + std::ios_base::seekdir dir, + std::ios_base::openmode which = std::ios_base::in) override { + auto pos = SharedStreamBuffer::seekoff(off, dir, which); + m_shared_obj->updateOffset(m_offset); + return pos; + } + protected: std::shared_ptr m_shared_obj; };