Add AlignedBuffer to OpenVINO developer API (#20532)

* Add AlignedBuffer to OpenVINO developer API

* Fixed build

* Fixed code style and remove opset deprecation

* Fixed Windows build

* Fixed GNA

* Fixed comment
This commit is contained in:
Ilya Churaev 2023-10-24 10:13:23 +04:00 committed by GitHub
parent 84a0994ec5
commit 7ceff55b71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 351 additions and 204 deletions

View File

@ -8,6 +8,7 @@
#include "Python.h" #include "Python.h"
#include "openvino/core/except.hpp" #include "openvino/core/except.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/common_util.hpp" #include "openvino/util/common_util.hpp"
#define C_CONTIGUOUS py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_ #define C_CONTIGUOUS py::detail::npy_api::constants::NPY_ARRAY_C_CONTIGUOUS_
@ -170,13 +171,12 @@ ov::op::v0::Constant create_copied(ov::Tensor& tensor) {
return ov::op::v0::Constant(tensor.get_element_type(), tensor.get_shape(), const_cast<void*>(tensor.data())); return ov::op::v0::Constant(tensor.get_element_type(), tensor.get_shape(), const_cast<void*>(tensor.data()));
} }
OPENVINO_SUPPRESS_DEPRECATED_START
template <> template <>
ov::op::v0::Constant create_shared(py::array& array) { ov::op::v0::Constant create_shared(py::array& array) {
// Check if passed array has C-style contiguous memory layout. // Check if passed array has C-style contiguous memory layout.
// If memory is going to be shared it needs to be contiguous before passing to the constructor. // If memory is going to be shared it needs to be contiguous before passing to the constructor.
if (array_helpers::is_contiguous(array)) { if (array_helpers::is_contiguous(array)) {
auto memory = std::make_shared<ngraph::runtime::SharedBuffer<py::array>>( auto memory = std::make_shared<ov::SharedBuffer<py::array>>(
static_cast<char*>(array.ndim() == 0 ? array.mutable_data() : array.mutable_data(0)), static_cast<char*>(array.ndim() == 0 ? array.mutable_data() : array.mutable_data(0)),
array.ndim() == 0 ? array.itemsize() : array.nbytes(), array.ndim() == 0 ? array.itemsize() : array.nbytes(),
array); array);
@ -185,7 +185,6 @@ ov::op::v0::Constant create_shared(py::array& array) {
// If passed array is not C-style, throw an error. // If passed array is not C-style, throw an error.
OPENVINO_THROW("SHARED MEMORY MODE FOR THIS CONSTANT IS NOT APPLICABLE! Passed numpy array must be C contiguous."); OPENVINO_THROW("SHARED MEMORY MODE FOR THIS CONSTANT IS NOT APPLICABLE! Passed numpy array must be C contiguous.");
} }
OPENVINO_SUPPRESS_DEPRECATED_END
template <> template <>
ov::op::v0::Constant create_shared(ov::Tensor& tensor) { ov::op::v0::Constant create_shared(ov::Tensor& tensor) {

View File

@ -15,6 +15,7 @@
#include "openvino/core/model.hpp" #include "openvino/core/model.hpp"
#include "openvino/op/util/framework_node.hpp" #include "openvino/op/util/framework_node.hpp"
#include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset1.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "transformations/rt_info/primitives_priority_attribute.hpp" #include "transformations/rt_info/primitives_priority_attribute.hpp"
namespace ov { namespace ov {
@ -180,6 +181,17 @@ public:
m_hash = hash_combine(m_hash, data[i]); m_hash = hash_combine(m_hash, data[i]);
} }
} }
} else if (const auto& a =
ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
if (name == "value" && m_node_type_name == "Constant") {
m_hash = hash_combine(m_hash, AttrType::constant);
const int64_t size = a->get()->size();
m_hash = hash_combine(hash_combine(m_hash, AttrType::size), size);
auto data = static_cast<const char*>(a->get()->get_ptr());
for (int64_t i = 0; i < size; i++) {
m_hash = hash_combine(m_hash, data[i]);
}
}
} else if (const auto& a = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) { } else if (const auto& a = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) {
const auto& attrs = a->get(); const auto& attrs = a->get();
// Update node attributes in data field // Update node attributes in data field

View File

@ -0,0 +1,75 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include <memory>
#include "openvino/core/attribute_adapter.hpp"
#include "openvino/core/core_visibility.hpp"
namespace ov {
/// \brief Allocates a block of memory on the specified alignment. The actual size of the
/// allocated memory is larger than the requested size by the alignment, so allocating 1
/// byte
/// on 64 byte alignment will allocate 65 bytes.
class OPENVINO_API AlignedBuffer {
public:
// Allocator objects and the allocation interfaces are owned by the
// creators of AlignedBuffers. They need to ensure that the lifetime of
// allocator exceeds the lifetime of this AlignedBuffer.
AlignedBuffer(size_t byte_size, size_t alignment = 64);
AlignedBuffer();
virtual ~AlignedBuffer();
AlignedBuffer(AlignedBuffer&& other);
AlignedBuffer& operator=(AlignedBuffer&& other);
size_t size() const {
return m_byte_size;
}
void* get_ptr(size_t offset) const {
return m_aligned_buffer + offset;
}
void* get_ptr() {
return m_aligned_buffer;
}
const void* get_ptr() const {
return m_aligned_buffer;
}
template <typename T>
T* get_ptr() {
return reinterpret_cast<T*>(m_aligned_buffer);
}
template <typename T>
const T* get_ptr() const {
return reinterpret_cast<const T*>(m_aligned_buffer);
}
template <typename T>
explicit operator T*() {
return get_ptr<T>();
}
private:
AlignedBuffer(const AlignedBuffer&) = delete;
AlignedBuffer& operator=(const AlignedBuffer&) = delete;
protected:
char* m_allocated_buffer;
char* m_aligned_buffer;
size_t m_byte_size;
};
template <>
class OPENVINO_API AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>
: public DirectValueAccessor<std::shared_ptr<ov::AlignedBuffer>> {
public:
AttributeAdapter(std::shared_ptr<ov::AlignedBuffer>& value);
OPENVINO_RTTI("AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>");
};
} // namespace ov

View File

@ -0,0 +1,31 @@
// Copyright (C) 2018-2023 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#pragma once
#include "openvino/runtime/aligned_buffer.hpp"
namespace ov {
/// \brief SharedBuffer class to store pointer to pre-acclocated buffer.
template <typename T>
class SharedBuffer : public ov::AlignedBuffer {
public:
SharedBuffer(char* data, size_t size, const T& shared_object) : _shared_object(shared_object) {
m_allocated_buffer = data;
m_aligned_buffer = data;
m_byte_size = size;
}
virtual ~SharedBuffer() {
m_aligned_buffer = nullptr;
m_allocated_buffer = nullptr;
m_byte_size = 0;
}
private:
T _shared_object;
};
} // namespace ov

View File

@ -30,7 +30,6 @@ struct NGRAPH_API_DEPRECATED oi_pair {
}; };
/// \brief Base class for annotations added to graph ops /// \brief Base class for annotations added to graph ops
class NGRAPH_API_DEPRECATED NGRAPH_API OpAnnotations { class NGRAPH_API_DEPRECATED NGRAPH_API OpAnnotations {
NGRAPH_SUPPRESS_DEPRECATED_START NGRAPH_SUPPRESS_DEPRECATED_START
public: public:

View File

@ -38,6 +38,7 @@ namespace ngraph {
// //
// A SlicePlan is used to collect parameters for these ops. // A SlicePlan is used to collect parameters for these ops.
// //
// This class is moved to dev API
struct NGRAPH_API_DEPRECATED NGRAPH_API SlicePlan { struct NGRAPH_API_DEPRECATED NGRAPH_API SlicePlan {
// Parameters for the Slice // Parameters for the Slice
std::vector<int64_t> begins; std::vector<int64_t> begins;

View File

@ -31,9 +31,7 @@ namespace ngraph {
class NGRAPH_API OpSet : public ov::OpSet { class NGRAPH_API OpSet : public ov::OpSet {
public: public:
explicit OpSet(const ov::OpSet& opset); explicit OpSet(const ov::OpSet& opset);
NGRAPH_SUPPRESS_DEPRECATED_START
OpSet(const ngraph::OpSet& opset); OpSet(const ngraph::OpSet& opset);
NGRAPH_SUPPRESS_DEPRECATED_END
OpSet() = default; OpSet() = default;
/// \brief Insert an op into the opset with a particular name and factory /// \brief Insert an op into the opset with a particular name and factory
void insert(const std::string& name, const NodeTypeInfo& type_info, FactoryRegistry<Node>::Factory factory) { void insert(const std::string& name, const NodeTypeInfo& type_info, FactoryRegistry<Node>::Factory factory) {
@ -56,19 +54,20 @@ public:
} }
}; };
const NGRAPH_API OpSet& get_opset1(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset1();
const NGRAPH_API OpSet& get_opset2(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset2();
const NGRAPH_API OpSet& get_opset3(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset3();
const NGRAPH_API OpSet& get_opset4(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset4();
const NGRAPH_API OpSet& get_opset5(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset5();
const NGRAPH_API OpSet& get_opset6(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset6();
const NGRAPH_API OpSet& get_opset7(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset7();
const NGRAPH_API OpSet& get_opset8(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset8();
const NGRAPH_API OpSet& get_opset9(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset9();
const NGRAPH_API OpSet& get_opset10(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset10();
const NGRAPH_API OpSet& get_opset11(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset11();
const NGRAPH_API OpSet& get_opset12(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset12();
const NGRAPH_API OpSet& get_opset13(); NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset13();
const NGRAPH_API std::map<std::string, std::function<const ngraph::OpSet&()>>& get_available_opsets(); NGRAPH_API_DEPRECATED const NGRAPH_API std::map<std::string, std::function<const ngraph::OpSet&()>>&
get_available_opsets();
} // namespace ngraph } // namespace ngraph
NGRAPH_SUPPRESS_DEPRECATED_END NGRAPH_SUPPRESS_DEPRECATED_END

View File

@ -12,7 +12,6 @@
# define WAS_OV_LIBRARY_DEFINED_CONSTANT # define WAS_OV_LIBRARY_DEFINED_CONSTANT
#endif #endif
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/shared_buffer.hpp" #include "ngraph/runtime/shared_buffer.hpp"
@ -21,11 +20,14 @@
# undef WAS_OV_LIBRARY_DEFINED_CONSTANT # undef WAS_OV_LIBRARY_DEFINED_CONSTANT
#endif #endif
#include "openvino/core/coordinate_diff.hpp" #include "openvino/core/coordinate_diff.hpp"
#include "openvino/core/node.hpp"
#include "openvino/core/type/element_type.hpp" #include "openvino/core/type/element_type.hpp"
#include "openvino/core/type/element_type_traits.hpp" #include "openvino/core/type/element_type_traits.hpp"
#include "openvino/op/op.hpp"
namespace ov { namespace ov {
class AlignedBuffer;
namespace op { namespace op {
namespace v0 { namespace v0 {
/// \brief Class for constants. /// \brief Class for constants.
@ -177,13 +179,20 @@ public:
/// \param shape The shape of the tensor constant. /// \param shape The shape of the tensor constant.
/// \param data A pointer to pre-allocated shared data. /// \param data A pointer to pre-allocated shared data.
template <typename T> template <typename T>
OPENVINO_DEPRECATED("This constructor is deprecated and will be removed in 2024.0 release")
Constant(const element::Type& type, const Shape& shape, std::shared_ptr<ngraph::runtime::SharedBuffer<T>> data) Constant(const element::Type& type, const Shape& shape, std::shared_ptr<ngraph::runtime::SharedBuffer<T>> data)
: m_element_type(type),
m_shape(shape) {
m_data = legacy_to_ov_aligned_buffer(data);
constructor_validate_and_infer_types();
}
OPENVINO_SUPPRESS_DEPRECATED_END
Constant(const element::Type& type, const Shape& shape, const std::shared_ptr<ov::AlignedBuffer>& data)
: m_element_type(type), : m_element_type(type),
m_shape(shape) { m_shape(shape) {
m_data = data; m_data = data;
constructor_validate_and_infer_types(); constructor_validate_and_infer_types();
} }
OPENVINO_SUPPRESS_DEPRECATED_END
Constant(const Constant& other); Constant(const Constant& other);
Constant(const Constant& other, const Shape& new_shape); Constant(const Constant& other, const Shape& new_shape);
@ -241,11 +250,7 @@ public:
AxisSet get_axis_set_val() const; AxisSet get_axis_set_val() const;
/// \brief Return data size in bytes /// \brief Return data size in bytes
size_t get_byte_size() const { size_t get_byte_size() const;
OPENVINO_SUPPRESS_DEPRECATED_START
return m_data->size();
OPENVINO_SUPPRESS_DEPRECATED_END
}
/// \brief Wrapper around constructing a shared_ptr of a Constant /// \brief Wrapper around constructing a shared_ptr of a Constant
/// ///
@ -370,11 +375,8 @@ public:
return rc; return rc;
} }
const void* get_data_ptr() const { const void* get_data_ptr() const;
OPENVINO_SUPPRESS_DEPRECATED_START
return (m_data ? m_data->get_ptr() : nullptr);
OPENVINO_SUPPRESS_DEPRECATED_END
}
template <typename T> template <typename T>
const T* get_data_ptr() const { const T* get_data_ptr() const {
OPENVINO_ASSERT(sizeof(T) <= m_element_type.size() || shape_size(m_shape) <= 0, "Buffer over-read"); OPENVINO_ASSERT(sizeof(T) <= m_element_type.size() || shape_size(m_shape) <= 0, "Buffer over-read");
@ -406,6 +408,11 @@ public:
private: private:
Constant(bool memset_allocation, const element::Type& type, const Shape& shape); Constant(bool memset_allocation, const element::Type& type, const Shape& shape);
OPENVINO_SUPPRESS_DEPRECATED_START
std::shared_ptr<ov::AlignedBuffer> legacy_to_ov_aligned_buffer(
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& buffer);
OPENVINO_SUPPRESS_DEPRECATED_END
template <element::Type_t Type, template <element::Type_t Type,
typename StorageDataType = fundamental_type_for<Type>, typename StorageDataType = fundamental_type_for<Type>,
typename std::enable_if<Type != element::Type_t::u1 && Type != element::Type_t::u4 && typename std::enable_if<Type != element::Type_t::u1 && Type != element::Type_t::u4 &&
@ -637,11 +644,7 @@ private:
void allocate_buffer(bool memset_allocation); void allocate_buffer(bool memset_allocation);
void* get_data_ptr_nc() { void* get_data_ptr_nc();
OPENVINO_SUPPRESS_DEPRECATED_START
return (m_data ? m_data->get_ptr() : nullptr);
OPENVINO_SUPPRESS_DEPRECATED_END
}
template <element::Type_t ET> template <element::Type_t ET>
typename element_type_traits<ET>::value_type* get_data_ptr_nc() { typename element_type_traits<ET>::value_type* get_data_ptr_nc() {
@ -853,9 +856,7 @@ private:
element::Type m_element_type; element::Type m_element_type;
Shape m_shape{}; Shape m_shape{};
OPENVINO_SUPPRESS_DEPRECATED_START std::shared_ptr<ov::AlignedBuffer> m_data;
std::shared_ptr<ngraph::runtime::AlignedBuffer> m_data;
OPENVINO_SUPPRESS_DEPRECATED_END
mutable std::atomic_bool m_all_elements_bitwise_identical{false}; mutable std::atomic_bool m_all_elements_bitwise_identical{false};
mutable std::atomic_bool m_all_elements_bitwise_identical_checked{false}; mutable std::atomic_bool m_all_elements_bitwise_identical_checked{false};
bool m_alloc_buffer_on_visit_attributes = true; bool m_alloc_buffer_on_visit_attributes = true;

View File

@ -8,10 +8,10 @@
#include <cmath> #include <cmath>
#include "ngraph/runtime/aligned_buffer.hpp"
#include "openvino/reference/reshape.hpp" #include "openvino/reference/reshape.hpp"
#include "openvino/reference/reverse.hpp" #include "openvino/reference/reverse.hpp"
#include "openvino/reference/slice.hpp" #include "openvino/reference/slice.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
namespace ov { namespace ov {
namespace reference { namespace reference {
@ -30,8 +30,7 @@ void strided_slice(const char* arg,
return; return;
} }
OPENVINO_SUPPRESS_DEPRECATED_START ov::AlignedBuffer slice_out_buffer(shape_size(sp.reshape_in_shape) * elem_type);
ngraph::runtime::AlignedBuffer slice_out_buffer(shape_size(sp.reshape_in_shape) * elem_type);
slice(reinterpret_cast<const char*>(arg), slice(reinterpret_cast<const char*>(arg),
slice_out_buffer.get_ptr<char>(), slice_out_buffer.get_ptr<char>(),
arg_shape, arg_shape,
@ -41,7 +40,7 @@ void strided_slice(const char* arg,
sp.reshape_in_shape, sp.reshape_in_shape,
elem_type); elem_type);
ngraph::runtime::AlignedBuffer reshape_out_buffer(shape_size(sp.reshape_out_shape) * elem_type); ov::AlignedBuffer reshape_out_buffer(shape_size(sp.reshape_out_shape) * elem_type);
reshape(slice_out_buffer.get_ptr<char>(), reshape_out_buffer.get_ptr<char>(), sp.reshape_in_shape, elem_type); reshape(slice_out_buffer.get_ptr<char>(), reshape_out_buffer.get_ptr<char>(), sp.reshape_in_shape, elem_type);
reverse(reshape_out_buffer.get_ptr<char>(), reverse(reshape_out_buffer.get_ptr<char>(),
@ -50,7 +49,6 @@ void strided_slice(const char* arg,
sp.reshape_out_shape, sp.reshape_out_shape,
sp.reverse_axes, sp.reverse_axes,
elem_type); elem_type);
OPENVINO_SUPPRESS_DEPRECATED_END
} }
} // namespace reference } // namespace reference
} // namespace ov } // namespace ov

View File

@ -10,8 +10,10 @@
#include <sstream> #include <sstream>
#include "itt.hpp" #include "itt.hpp"
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/host_tensor.hpp" #include "ngraph/runtime/host_tensor.hpp"
#include "ngraph/runtime/tensor.hpp" #include "ngraph/runtime/tensor.hpp"
#include "openvino/runtime/shared_buffer.hpp"
template <typename T> template <typename T>
static inline std::string to_cpp_string(T value) { static inline std::string to_cpp_string(T value) {
@ -27,6 +29,14 @@ static inline std::string to_cpp_string(T value) {
} }
return rc; return rc;
} }
OPENVINO_SUPPRESS_DEPRECATED_START
std::shared_ptr<ov::AlignedBuffer> ov::op::v0::Constant::legacy_to_ov_aligned_buffer(
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& buffer) {
return std::make_shared<ov::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(buffer->get_ptr<char>(),
buffer->size(),
buffer);
}
OPENVINO_SUPPRESS_DEPRECATED_END
OPENVINO_SUPPRESS_DEPRECATED_START OPENVINO_SUPPRESS_DEPRECATED_START
ov::op::v0::Constant::Constant(const std::shared_ptr<ngraph::runtime::Tensor>& tensor) { ov::op::v0::Constant::Constant(const std::shared_ptr<ngraph::runtime::Tensor>& tensor) {
@ -35,7 +45,7 @@ ov::op::v0::Constant::Constant(const std::shared_ptr<ngraph::runtime::Tensor>& t
// Share data from HostTensor if we work with it // Share data from HostTensor if we work with it
// And copy data in other cas // And copy data in other cas
if (auto hostTensor = std::dynamic_pointer_cast<ngraph::runtime::HostTensor>(tensor)) { if (auto hostTensor = std::dynamic_pointer_cast<ngraph::runtime::HostTensor>(tensor)) {
m_data = std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::Tensor>>>( m_data = std::make_shared<ov::SharedBuffer<std::shared_ptr<ngraph::runtime::Tensor>>>(
static_cast<char*>(hostTensor->get_data_ptr()), static_cast<char*>(hostTensor->get_data_ptr()),
tensor->get_size_in_bytes(), tensor->get_size_in_bytes(),
tensor); tensor);
@ -51,12 +61,10 @@ OPENVINO_SUPPRESS_DEPRECATED_END
ov::op::v0::Constant::Constant(const ov::Tensor& tensor) { ov::op::v0::Constant::Constant(const ov::Tensor& tensor) {
m_element_type = tensor.get_element_type(); m_element_type = tensor.get_element_type();
m_shape = tensor.get_shape(); m_shape = tensor.get_shape();
OPENVINO_SUPPRESS_DEPRECATED_START
// Share data from ov::Tensor // Share data from ov::Tensor
m_data = std::make_shared<ngraph::runtime::SharedBuffer<ov::Tensor>>(static_cast<char*>(tensor.data()), m_data = std::make_shared<ov::SharedBuffer<ov::Tensor>>(static_cast<char*>(tensor.data()),
tensor.get_byte_size(), tensor.get_byte_size(),
tensor); tensor);
OPENVINO_SUPPRESS_DEPRECATED_END
constructor_validate_and_infer_types(); constructor_validate_and_infer_types();
} }
@ -211,12 +219,10 @@ ov::op::v0::Constant::Constant(bool memset_allocation, const element::Type& type
} }
void ov::op::v0::Constant::allocate_buffer(bool memset_allocation) { void ov::op::v0::Constant::allocate_buffer(bool memset_allocation) {
OPENVINO_SUPPRESS_DEPRECATED_START m_data = std::make_shared<ov::AlignedBuffer>(mem_size(), host_alignment());
m_data = std::make_shared<ngraph::runtime::AlignedBuffer>(mem_size(), host_alignment());
if (memset_allocation) { if (memset_allocation) {
std::memset(m_data->get_ptr(), 0, m_data->size()); std::memset(m_data->get_ptr(), 0, m_data->size());
} }
OPENVINO_SUPPRESS_DEPRECATED_END
} }
ov::op::v0::Constant::Constant(const element::Type& type, const ov::Shape& shape, const void* data) ov::op::v0::Constant::Constant(const element::Type& type, const ov::Shape& shape, const void* data)
@ -316,6 +322,18 @@ std::string ov::op::v0::Constant::convert_value_to_string(size_t index) const {
return rc; return rc;
} }
size_t ov::op::v0::Constant::get_byte_size() const {
return m_data->size();
}
const void* ov::op::v0::Constant::get_data_ptr() const {
return (m_data ? m_data->get_ptr() : nullptr);
}
void* ov::op::v0::Constant::get_data_ptr_nc() {
return (m_data ? m_data->get_ptr() : nullptr);
}
std::vector<std::string> ov::op::v0::Constant::get_value_strings() const { std::vector<std::string> ov::op::v0::Constant::get_value_strings() const {
std::vector<std::string> rc; std::vector<std::string> rc;

View File

@ -21,6 +21,7 @@
#include "openvino/opsets/opset1.hpp" #include "openvino/opsets/opset1.hpp"
#include "openvino/pass/constant_folding.hpp" #include "openvino/pass/constant_folding.hpp"
#include "openvino/reference/convert.hpp" #include "openvino/reference/convert.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/util/file_util.hpp" #include "openvino/util/file_util.hpp"
#include "pugixml.hpp" #include "pugixml.hpp"
#include "transformations/hash.hpp" #include "transformations/hash.hpp"
@ -532,6 +533,19 @@ public:
m_xml_node.append_attribute("offset").set_value(static_cast<unsigned long long>(offset)); m_xml_node.append_attribute("offset").set_value(static_cast<unsigned long long>(offset));
m_xml_node.append_attribute("size").set_value(static_cast<unsigned long long>(new_size)); m_xml_node.append_attribute("size").set_value(static_cast<unsigned long long>(new_size));
} }
} else if (const auto& a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
if (name == "value" && translate_type_name(m_node_type_name) == "Const") {
const int64_t size = a->get()->size();
size_t new_size;
int64_t offset = m_constant_write_handler.write(static_cast<const char*>(a->get()->get_ptr()),
size,
&new_size,
m_compress_to_fp16,
m_output_element_type);
m_xml_node.append_attribute("offset").set_value(static_cast<unsigned long long>(offset));
m_xml_node.append_attribute("size").set_value(static_cast<unsigned long long>(new_size));
}
} else if (const auto& a = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) { } else if (const auto& a = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) {
const auto& attrs = a->get(); const auto& attrs = a->get();

View File

@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "ngraph/util.hpp" #include "ngraph/util.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/util/log.hpp" #include "openvino/util/log.hpp"
NGRAPH_SUPPRESS_DEPRECATED_START NGRAPH_SUPPRESS_DEPRECATED_START
@ -64,3 +65,53 @@ AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>::AttributeAdap
std::shared_ptr<ngraph::runtime::AlignedBuffer>& value) std::shared_ptr<ngraph::runtime::AlignedBuffer>& value)
: DirectValueAccessor<std::shared_ptr<ngraph::runtime::AlignedBuffer>>(value) {} : DirectValueAccessor<std::shared_ptr<ngraph::runtime::AlignedBuffer>>(value) {}
} // namespace ov } // namespace ov
NGRAPH_SUPPRESS_DEPRECATED_END
namespace ov {
AlignedBuffer::AlignedBuffer() : m_allocated_buffer(nullptr), m_aligned_buffer(nullptr), m_byte_size(0) {}
AlignedBuffer::AlignedBuffer(size_t byte_size, size_t alignment) : m_byte_size(byte_size) {
m_byte_size = std::max<size_t>(1, byte_size);
size_t allocation_size = m_byte_size + alignment;
m_allocated_buffer = new char[allocation_size];
m_aligned_buffer = m_allocated_buffer;
size_t mod = (alignment != 0) ? reinterpret_cast<size_t>(m_aligned_buffer) % alignment : 0;
if (mod != 0) {
m_aligned_buffer += (alignment - mod);
}
}
AlignedBuffer::AlignedBuffer(AlignedBuffer&& other)
: m_allocated_buffer(other.m_allocated_buffer),
m_aligned_buffer(other.m_aligned_buffer),
m_byte_size(other.m_byte_size) {
other.m_allocated_buffer = nullptr;
other.m_aligned_buffer = nullptr;
other.m_byte_size = 0;
}
AlignedBuffer::~AlignedBuffer() {
if (m_allocated_buffer != nullptr) {
delete[] m_allocated_buffer;
}
}
AlignedBuffer& AlignedBuffer::operator=(AlignedBuffer&& other) {
if (this != &other) {
if (m_allocated_buffer != nullptr) {
delete[] m_allocated_buffer;
}
m_allocated_buffer = other.m_allocated_buffer;
m_aligned_buffer = other.m_aligned_buffer;
m_byte_size = other.m_byte_size;
other.m_allocated_buffer = nullptr;
other.m_aligned_buffer = nullptr;
other.m_byte_size = 0;
}
return *this;
}
AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>::AttributeAdapter(std::shared_ptr<ov::AlignedBuffer>& value)
: DirectValueAccessor<std::shared_ptr<ov::AlignedBuffer>>(value) {}
} // namespace ov

View File

@ -2,31 +2,30 @@
// SPDX-License-Identifier: Apache-2.0 // SPDX-License-Identifier: Apache-2.0
// //
#include "ngraph/runtime/aligned_buffer.hpp" #include "openvino/runtime/aligned_buffer.hpp"
#include "gtest/gtest.h" #include "gtest/gtest.h"
using namespace ngraph; using namespace ov;
OPENVINO_SUPPRESS_DEPRECATED_START
TEST(aligned_buffer, alignment) { TEST(aligned_buffer, alignment) {
runtime::AlignedBuffer buffer(100, 64); AlignedBuffer buffer(100, 64);
size_t addr = reinterpret_cast<size_t>(buffer.get_ptr()) % 64; size_t addr = reinterpret_cast<size_t>(buffer.get_ptr()) % 64;
EXPECT_EQ(addr, 0); EXPECT_EQ(addr, 0);
} }
TEST(aligned_buffer, move) { TEST(aligned_buffer, move) {
{ {
runtime::AlignedBuffer buffer1(100, 64); AlignedBuffer buffer1(100, 64);
runtime::AlignedBuffer buffer2(std::move(buffer1)); AlignedBuffer buffer2(std::move(buffer1));
EXPECT_EQ(buffer1.size(), 0); EXPECT_EQ(buffer1.size(), 0);
EXPECT_EQ(buffer1.get_ptr(), nullptr); EXPECT_EQ(buffer1.get_ptr(), nullptr);
EXPECT_EQ(buffer2.size(), 100); EXPECT_EQ(buffer2.size(), 100);
EXPECT_NE(buffer2.get_ptr(), nullptr); EXPECT_NE(buffer2.get_ptr(), nullptr);
} }
{ {
runtime::AlignedBuffer buffer1(100, 64); AlignedBuffer buffer1(100, 64);
runtime::AlignedBuffer buffer2; AlignedBuffer buffer2;
buffer2 = std::move(buffer1); buffer2 = std::move(buffer1);
EXPECT_EQ(buffer1.size(), 0); EXPECT_EQ(buffer1.size(), 0);
EXPECT_EQ(buffer1.get_ptr(), nullptr); EXPECT_EQ(buffer1.get_ptr(), nullptr);

View File

@ -10,7 +10,7 @@
#include <random> #include <random>
#include "common_test_utils/float_util.hpp" #include "common_test_utils/float_util.hpp"
#include "ngraph/runtime/aligned_buffer.hpp" #include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/util/log.hpp" #include "openvino/util/log.hpp"
using namespace std; using namespace std;
@ -140,9 +140,8 @@ TEST(bfloat16, numeric_limits) {
} }
TEST(benchmark, bfloat16) { TEST(benchmark, bfloat16) {
OPENVINO_SUPPRESS_DEPRECATED_START
size_t buffer_size = 128 * 3 * 224 * 224; size_t buffer_size = 128 * 3 * 224 * 224;
ngraph::runtime::AlignedBuffer data(buffer_size * sizeof(float), 4096); ov::AlignedBuffer data(buffer_size * sizeof(float), 4096);
float* f = static_cast<float*>(data.get_ptr()); float* f = static_cast<float*>(data.get_ptr());
// vector<float> data(buffer_size); // vector<float> data(buffer_size);
std::mt19937 rng(2112); std::mt19937 rng(2112);
@ -153,53 +152,36 @@ TEST(benchmark, bfloat16) {
OPENVINO_INFO << "buffer size " << buffer_size << " floats or " << data.size() << " bytes"; OPENVINO_INFO << "buffer size " << buffer_size << " floats or " << data.size() << " bytes";
{ {
ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); ov::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096);
bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr()); bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr());
ngraph::stopwatch timer;
timer.start();
for (size_t i = 0; i < buffer_size; ++i) { for (size_t i = 0; i < buffer_size; ++i) {
p[i] = bfloat16(f[i]); p[i] = bfloat16(f[i]);
} }
timer.stop();
OPENVINO_INFO << "float to bfloat16 ctor " << timer.get_milliseconds() << "ms";
} }
{ {
ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); ov::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096);
bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr()); bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr());
ngraph::stopwatch timer;
timer.start();
for (size_t i = 0; i < buffer_size; ++i) { for (size_t i = 0; i < buffer_size; ++i) {
p[i] = bfloat16::truncate(f[i]); p[i] = bfloat16::truncate(f[i]);
} }
timer.stop();
OPENVINO_INFO << "float to bfloat16 truncate " << timer.get_milliseconds() << "ms";
} }
{ {
ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); ov::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096);
bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr()); bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr());
ngraph::stopwatch timer;
timer.start();
for (size_t i = 0; i < buffer_size; ++i) { for (size_t i = 0; i < buffer_size; ++i) {
p[i] = bfloat16::round_to_nearest(f[i]); p[i] = bfloat16::round_to_nearest(f[i]);
} }
timer.stop();
OPENVINO_INFO << "float to bfloat16 round to nearest " << timer.get_milliseconds() << "ms";
} }
{ {
ngraph::runtime::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096); ov::AlignedBuffer bf_data(buffer_size * sizeof(bfloat16), 4096);
bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr()); bfloat16* p = static_cast<bfloat16*>(bf_data.get_ptr());
ngraph::stopwatch timer;
timer.start();
for (size_t i = 0; i < buffer_size; ++i) { for (size_t i = 0; i < buffer_size; ++i) {
p[i] = bfloat16::round_to_nearest_even(f[i]); p[i] = bfloat16::round_to_nearest_even(f[i]);
} }
timer.stop();
OPENVINO_INFO << "float to bfloat16 round to nearest even " << timer.get_milliseconds() << "ms";
} }
OPENVINO_SUPPRESS_DEPRECATED_END
} }
TEST(bfloat16, assigns) { TEST(bfloat16, assigns) {

View File

@ -10,6 +10,8 @@
#include "common_test_utils/type_prop.hpp" #include "common_test_utils/type_prop.hpp"
#include "openvino/core/except.hpp" #include "openvino/core/except.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/shared_buffer.hpp"
using namespace ov; using namespace ov;
using namespace std; using namespace std;
@ -1726,14 +1728,12 @@ TEST(constant, lazy_bitwise_identical) {
auto shape = Shape{10, 1000, 1000}; auto shape = Shape{10, 1000, 1000};
auto type = element::i32; auto type = element::i32;
auto byte_size = shape_size(shape) * sizeof(int32_t); auto byte_size = shape_size(shape) * sizeof(int32_t);
OPENVINO_SUPPRESS_DEPRECATED_START auto aligned_weights_buffer = std::make_shared<ov::AlignedBuffer>(byte_size);
auto aligned_weights_buffer = std::make_shared<ngraph::runtime::AlignedBuffer>(byte_size);
std::memset(aligned_weights_buffer->get_ptr<char>(), 1, byte_size); std::memset(aligned_weights_buffer->get_ptr<char>(), 1, byte_size);
auto weights = std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>( auto weights =
aligned_weights_buffer->get_ptr<char>(), std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(aligned_weights_buffer->get_ptr<char>(),
aligned_weights_buffer->size(), aligned_weights_buffer->size(),
aligned_weights_buffer); aligned_weights_buffer);
OPENVINO_SUPPRESS_DEPRECATED_END
using namespace std::chrono; using namespace std::chrono;
auto create_constant = [&]() { auto create_constant = [&]() {

View File

@ -10,12 +10,13 @@
#include <vector> #include <vector>
#include "ngraph/factory.hpp" #include "ngraph/factory.hpp"
#include "ngraph/runtime/aligned_buffer.hpp"
#include "openvino/core/attribute_visitor.hpp" #include "openvino/core/attribute_visitor.hpp"
#include "openvino/core/deprecated.hpp" #include "openvino/core/deprecated.hpp"
#include "openvino/op/util/framework_node.hpp" #include "openvino/op/util/framework_node.hpp"
#include "openvino/op/util/sub_graph_base.hpp" #include "openvino/op/util/sub_graph_base.hpp"
#include "openvino/op/util/variable.hpp" #include "openvino/op/util/variable.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/tensor.hpp"
namespace ov { namespace ov {
namespace test { namespace test {
@ -217,10 +218,9 @@ public:
} }
void on_adapter(const std::string& name, ValueAccessor<void>& adapter) override { void on_adapter(const std::string& name, ValueAccessor<void>& adapter) override {
OPENVINO_SUPPRESS_DEPRECATED_START if (auto a = ::ov::as_type<::ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
if (auto a = ::ov::as_type<::ov::AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(&adapter)) { auto& data = m_values.get<ov::Tensor>(name);
auto& data = m_values.get<ngraph::HostTensorPtr>(name); std::memcpy(a->get()->get_ptr(), data.data(), a->get()->size());
data->read(a->get()->get_ptr(), a->get()->size());
} else if (auto a = ov::as_type< } else if (auto a = ov::as_type<
ov::AttributeAdapter<std::vector<std::shared_ptr<ov::op::util::SubGraphOp::OutputDescription>>>>( ov::AttributeAdapter<std::vector<std::shared_ptr<ov::op::util::SubGraphOp::OutputDescription>>>>(
&adapter)) { &adapter)) {
@ -240,7 +240,6 @@ public:
} else { } else {
OPENVINO_THROW("Attribute \"", name, "\" cannot be unmarshalled"); OPENVINO_THROW("Attribute \"", name, "\" cannot be unmarshalled");
} }
OPENVINO_SUPPRESS_DEPRECATED_END
} }
// The remaining adapter methods fall back on the void adapter if not implemented // The remaining adapter methods fall back on the void adapter if not implemented
void on_adapter(const std::string& name, ValueAccessor<std::string>& adapter) override { void on_adapter(const std::string& name, ValueAccessor<std::string>& adapter) override {
@ -309,10 +308,9 @@ public:
} }
void on_adapter(const std::string& name, ValueAccessor<void>& adapter) override { void on_adapter(const std::string& name, ValueAccessor<void>& adapter) override {
OPENVINO_SUPPRESS_DEPRECATED_START if (auto a = ::ov::as_type<::ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
if (auto a = ::ov::as_type<::ov::AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(&adapter)) { ov::Tensor data(element::u8, Shape{a->get()->size()});
ngraph::HostTensorPtr data = std::make_shared<ngraph::HostTensor>(element::u8, Shape{a->get()->size()}); std::memcpy(data.data(), a->get()->get_ptr(), a->get()->size());
data->write(a->get()->get_ptr(), a->get()->size());
m_values.insert(name, data); m_values.insert(name, data);
} else if (auto a = ov::as_type< } else if (auto a = ov::as_type<
ov::AttributeAdapter<std::vector<std::shared_ptr<ov::op::util::SubGraphOp::OutputDescription>>>>( ov::AttributeAdapter<std::vector<std::shared_ptr<ov::op::util::SubGraphOp::OutputDescription>>>>(
@ -333,7 +331,6 @@ public:
} else { } else {
OPENVINO_THROW("Attribute \"", name, "\" cannot be marshalled"); OPENVINO_THROW("Attribute \"", name, "\" cannot be marshalled");
} }
OPENVINO_SUPPRESS_DEPRECATED_END
} }
// The remaining adapter methods fall back on the void adapter if not implemented // The remaining adapter methods fall back on the void adapter if not implemented
void on_adapter(const std::string& name, ValueAccessor<std::string>& adapter) override { void on_adapter(const std::string& name, ValueAccessor<std::string>& adapter) override {

View File

@ -9,10 +9,10 @@
#include <vector> #include <vector>
#include "input_model.hpp" #include "input_model.hpp"
#include "ngraph/runtime/aligned_buffer.hpp"
#include "ngraph/runtime/shared_buffer.hpp"
#include "openvino/core/any.hpp" #include "openvino/core/any.hpp"
#include "openvino/core/so_extension.hpp" #include "openvino/core/so_extension.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/file_util.hpp" #include "openvino/util/file_util.hpp"
#include "openvino/util/mmap_object.hpp" #include "openvino/util/mmap_object.hpp"
#include "transformations/resolve_names_collisions.hpp" #include "transformations/resolve_names_collisions.hpp"
@ -116,8 +116,7 @@ void FrontEnd::add_extension(const ov::Extension::Ptr& ext) {
InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const { InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const {
std::ifstream local_model_stream; std::ifstream local_model_stream;
std::istream* provided_model_stream = nullptr; std::istream* provided_model_stream = nullptr;
OPENVINO_SUPPRESS_DEPRECATED_START std::shared_ptr<ov::AlignedBuffer> weights;
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights;
auto create_extensions_map = [&]() -> std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> { auto create_extensions_map = [&]() -> std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> {
std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> exts; std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> exts;
@ -180,8 +179,8 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
} else if (variant.is<std::wstring>()) { } else if (variant.is<std::wstring>()) {
weights_path = variant.as<std::wstring>(); weights_path = variant.as<std::wstring>();
#endif #endif
} else if (variant.is<std::shared_ptr<ngraph::runtime::AlignedBuffer>>()) { } else if (variant.is<std::shared_ptr<ov::AlignedBuffer>>()) {
weights = variant.as<std::shared_ptr<ngraph::runtime::AlignedBuffer>>(); weights = variant.as<std::shared_ptr<ov::AlignedBuffer>>();
} }
} }
bool enable_mmap = variants[variants.size() - 1].is<bool>() ? variants[variants.size() - 1].as<bool>() : false; bool enable_mmap = variants[variants.size() - 1].is<bool>() ? variants[variants.size() - 1].as<bool>() : false;
@ -204,8 +203,7 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
if (!weights_path.empty()) { if (!weights_path.empty()) {
if (enable_mmap) { if (enable_mmap) {
auto mapped_memory = ov::load_mmap_object(weights_path); auto mapped_memory = ov::load_mmap_object(weights_path);
weights = weights = std::make_shared<ov::SharedBuffer<std::shared_ptr<MappedMemory>>>(mapped_memory->data(),
std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<MappedMemory>>>(mapped_memory->data(),
mapped_memory->size(), mapped_memory->size(),
mapped_memory); mapped_memory);
} else { } else {
@ -222,17 +220,16 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
size_t file_size = bin_stream.tellg(); size_t file_size = bin_stream.tellg();
bin_stream.seekg(0, std::ios::beg); bin_stream.seekg(0, std::ios::beg);
auto aligned_weights_buffer = std::make_shared<ngraph::runtime::AlignedBuffer>(file_size); auto aligned_weights_buffer = std::make_shared<ov::AlignedBuffer>(file_size);
bin_stream.read(aligned_weights_buffer->get_ptr<char>(), aligned_weights_buffer->size()); bin_stream.read(aligned_weights_buffer->get_ptr<char>(), aligned_weights_buffer->size());
bin_stream.close(); bin_stream.close();
weights = std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>( weights = std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(
aligned_weights_buffer->get_ptr<char>(), aligned_weights_buffer->get_ptr<char>(),
aligned_weights_buffer->size(), aligned_weights_buffer->size(),
aligned_weights_buffer); aligned_weights_buffer);
} }
} }
OPENVINO_SUPPRESS_DEPRECATED_END
return create_input_model(); return create_input_model();
} }

View File

@ -18,10 +18,9 @@
#include "openvino/util/common_util.hpp" #include "openvino/util/common_util.hpp"
#include "utils.hpp" #include "utils.hpp"
OPENVINO_SUPPRESS_DEPRECATED_START
namespace { namespace {
void parse_pre_process(pugi::xml_node& root, void parse_pre_process(pugi::xml_node& root,
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights, std::shared_ptr<ov::AlignedBuffer> weights,
std::shared_ptr<ov::Model> model) { std::shared_ptr<ov::Model> model) {
/* Preprocessing block can have two preprocessing types: /* Preprocessing block can have two preprocessing types:
* *
@ -183,7 +182,9 @@ void parse_pre_process(pugi::xml_node& root,
const char* data = weights->get_ptr<char>() + offset; const char* data = weights->get_ptr<char>() + offset;
per_channel_values[item.first] = ov::op::v0::Constant::create(input_type, mean_shape, data); per_channel_values[item.first] = ov::op::v0::Constant::create(input_type, mean_shape, data);
} }
OPENVINO_SUPPRESS_DEPRECATED_START
auto const_node = get_constant_from_source(std::make_shared<ov::op::v0::Concat>(per_channel_values, 0)); auto const_node = get_constant_from_source(std::make_shared<ov::op::v0::Concat>(per_channel_values, 0));
OPENVINO_SUPPRESS_DEPRECATED_END
OPENVINO_ASSERT(const_node); OPENVINO_ASSERT(const_node);
const auto& consumers = input_node->output(0).get_target_inputs(); const auto& consumers = input_node->output(0).get_target_inputs();
auto add = std::make_shared<ov::op::v1::Subtract>(input_node, const_node); auto add = std::make_shared<ov::op::v1::Subtract>(input_node, const_node);
@ -193,15 +194,13 @@ void parse_pre_process(pugi::xml_node& root,
} }
} }
} // namespace } // namespace
OPENVINO_SUPPRESS_DEPRECATED_END
namespace ov { namespace ov {
namespace frontend { namespace frontend {
namespace ir { namespace ir {
OPENVINO_SUPPRESS_DEPRECATED_START
class InputModel::InputModelIRImpl { class InputModel::InputModelIRImpl {
std::shared_ptr<ngraph::runtime::AlignedBuffer> m_weights; std::shared_ptr<ov::AlignedBuffer> m_weights;
std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> m_extensions; std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> m_extensions;
std::unordered_map<std::string, ov::OpSet> m_opsets; std::unordered_map<std::string, ov::OpSet> m_opsets;
pugi::xml_node m_root; pugi::xml_node m_root;
@ -209,7 +208,7 @@ class InputModel::InputModelIRImpl {
public: public:
InputModelIRImpl(std::istream& stream, InputModelIRImpl(std::istream& stream,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights, const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions) const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions)
: m_weights(weights), : m_weights(weights),
m_extensions(extensions) { m_extensions(extensions) {
@ -227,11 +226,10 @@ public:
}; };
InputModel::InputModel(std::istream& stream, InputModel::InputModel(std::istream& stream,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights, const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions) { const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions) {
_impl = std::make_shared<InputModelIRImpl>(stream, weights, extensions); _impl = std::make_shared<InputModelIRImpl>(stream, weights, extensions);
} }
OPENVINO_SUPPRESS_DEPRECATED_END
std::shared_ptr<ov::Model> InputModel::convert() { std::shared_ptr<ov::Model> InputModel::convert() {
return _impl->convert(); return _impl->convert();

View File

@ -7,9 +7,9 @@
#include <istream> #include <istream>
#include <memory> #include <memory>
#include "ngraph/runtime/aligned_buffer.hpp"
#include "openvino/frontend/manager.hpp" #include "openvino/frontend/manager.hpp"
#include "openvino/frontend/visibility.hpp" #include "openvino/frontend/visibility.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
namespace ov { namespace ov {
namespace frontend { namespace frontend {
@ -20,11 +20,9 @@ class InputModel : public ov::frontend::InputModel {
std::shared_ptr<InputModelIRImpl> _impl; std::shared_ptr<InputModelIRImpl> _impl;
public: public:
OPENVINO_SUPPRESS_DEPRECATED_START
InputModel(std::istream& stream, InputModel(std::istream& stream,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights, const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions); const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions);
OPENVINO_SUPPRESS_DEPRECATED_END
std::shared_ptr<Model> convert(); std::shared_ptr<Model> convert();
}; };

View File

@ -20,6 +20,8 @@
#include "openvino/op/util/read_value_base.hpp" #include "openvino/op/util/read_value_base.hpp"
#include "openvino/op/util/sub_graph_base.hpp" #include "openvino/op/util/sub_graph_base.hpp"
#include "openvino/op/util/variable.hpp" #include "openvino/op/util/variable.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "rt_info_deserializer.hpp" #include "rt_info_deserializer.hpp"
#include "transformations/rt_info/attributes.hpp" #include "transformations/rt_info/attributes.hpp"
#include "utils.hpp" #include "utils.hpp"
@ -258,7 +260,6 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
if (skip_names.count(name) && !getStrAttribute(m_node.child("data"), name, val)) if (skip_names.count(name) && !getStrAttribute(m_node.child("data"), name, val))
return; return;
OPENVINO_SUPPRESS_DEPRECATED_START
if (auto a = ov::as_type<ov::AttributeAdapter<ov::element::Type>>(&adapter)) { if (auto a = ov::as_type<ov::AttributeAdapter<ov::element::Type>>(&adapter)) {
static_cast<ov::element::Type&>(*a) = ov::element::Type(val); static_cast<ov::element::Type&>(*a) = ov::element::Type(val);
} else if (auto a = ov::as_type<ov::AttributeAdapter<PartialShape>>(&adapter)) { } else if (auto a = ov::as_type<ov::AttributeAdapter<PartialShape>>(&adapter)) {
@ -322,7 +323,7 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
ov::op::util::VariableInfo{ov::PartialShape::dynamic(), ov::element::dynamic, variable_id}); ov::op::util::VariableInfo{ov::PartialShape::dynamic(), ov::element::dynamic, variable_id});
} }
a->set(m_variables[variable_id]); a->set(m_variables[variable_id]);
} else if (auto a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(&adapter)) { } else if (auto a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
std::string value; std::string value;
pugi::xml_node dn = m_node.child("data"); pugi::xml_node dn = m_node.child("data");
auto type = pugixml::utils::get_str_attr(m_node, "type"); auto type = pugixml::utils::get_str_attr(m_node, "type");
@ -331,7 +332,7 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
OPENVINO_THROW("No attrtibutes defined for ", type, " op!"); OPENVINO_THROW("No attrtibutes defined for ", type, " op!");
if (getStrAttribute(dn, name, value)) { if (getStrAttribute(dn, name, value)) {
auto buffer = std::make_shared<ngraph::runtime::AlignedBuffer>(value.size()); auto buffer = std::make_shared<ov::AlignedBuffer>(value.size());
auto data = static_cast<char*>(buffer->get_ptr()); auto data = static_cast<char*>(buffer->get_ptr());
value.copy(data, value.size()); value.copy(data, value.size());
a->set(buffer); a->set(buffer);
@ -356,11 +357,7 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
OPENVINO_THROW("Attribute and shape size are inconsistent for ", type, " op!"); OPENVINO_THROW("Attribute and shape size are inconsistent for ", type, " op!");
char* data = m_weights->get_ptr<char>() + offset; char* data = m_weights->get_ptr<char>() + offset;
auto buffer = auto buffer = std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(data, size, m_weights);
std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(
data,
size,
m_weights);
a->set(buffer); a->set(buffer);
} }
} else if (auto a = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) { } else if (auto a = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) {
@ -388,7 +385,6 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
} else { } else {
OPENVINO_THROW("Error IR reading. Attribute adapter can not be found for ", name, " parameter"); OPENVINO_THROW("Error IR reading. Attribute adapter can not be found for ", name, " parameter");
} }
OPENVINO_SUPPRESS_DEPRECATED_END
} }
void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) { void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<std::shared_ptr<ov::Model>>& adapter) {
@ -409,10 +405,8 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
adapter.set(model); adapter.set(model);
} }
OPENVINO_SUPPRESS_DEPRECATED_START std::shared_ptr<ov::Model> ov::XmlDeserializer::parse_function(const pugi::xml_node& root,
std::shared_ptr<ov::Model> ov::XmlDeserializer::parse_function( const std::shared_ptr<ov::AlignedBuffer>& weights) {
const pugi::xml_node& root,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights) {
// OV_ITT_SCOPE_CHAIN(FIRST_INFERENCE, taskChain, itt::domains::V10Reader_RT, "V10Parser", "Parse"); // OV_ITT_SCOPE_CHAIN(FIRST_INFERENCE, taskChain, itt::domains::V10Reader_RT, "V10Parser", "Parse");
struct FunctionNodes { struct FunctionNodes {
@ -553,7 +547,6 @@ std::shared_ptr<ov::Model> ov::XmlDeserializer::parse_function(
return function; return function;
} }
OPENVINO_SUPPRESS_DEPRECATED_END
class MetaDataParser : public ov::Meta { class MetaDataParser : public ov::Meta {
public: public:
@ -751,11 +744,9 @@ static const std::string& translate_type_name(const std::string& name) {
return name; return name;
} }
OPENVINO_SUPPRESS_DEPRECATED_START std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(const std::vector<ov::Output<ov::Node>>& inputs,
std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(
const std::vector<ov::Output<ov::Node>>& inputs,
const pugi::xml_node& node, const pugi::xml_node& node,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights, const std::shared_ptr<ov::AlignedBuffer>& weights,
const GenericLayerParams& params) { const GenericLayerParams& params) {
// Check that inputs are correctly defined // Check that inputs are correctly defined
for (size_t i = 0; i < inputs.size(); i++) { for (size_t i = 0; i < inputs.size(); i++) {
@ -959,4 +950,3 @@ std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(
return ovNode; return ovNode;
} }
OPENVINO_SUPPRESS_DEPRECATED_END

View File

@ -10,11 +10,11 @@
#include <pugixml.hpp> #include <pugixml.hpp>
#include "input_model.hpp" #include "input_model.hpp"
#include "ngraph/runtime/aligned_buffer.hpp"
#include "openvino/core/attribute_visitor.hpp" #include "openvino/core/attribute_visitor.hpp"
#include "openvino/core/op_extension.hpp" #include "openvino/core/op_extension.hpp"
#include "openvino/op/loop.hpp" #include "openvino/op/loop.hpp"
#include "openvino/op/util/sub_graph_base.hpp" #include "openvino/op/util/sub_graph_base.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "utils.hpp" #include "utils.hpp"
namespace ov { namespace ov {
@ -58,9 +58,8 @@ struct GenericLayerParams {
class XmlDeserializer : public ov::AttributeVisitor { class XmlDeserializer : public ov::AttributeVisitor {
public: public:
OPENVINO_SUPPRESS_DEPRECATED_START
explicit XmlDeserializer(const pugi::xml_node& node, explicit XmlDeserializer(const pugi::xml_node& node,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights, const std::shared_ptr<ov::AlignedBuffer>& weights,
const std::unordered_map<std::string, ov::OpSet>& opsets, const std::unordered_map<std::string, ov::OpSet>& opsets,
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions, const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& variables, std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& variables,
@ -71,7 +70,6 @@ public:
m_extensions(extensions), m_extensions(extensions),
m_variables(variables), m_variables(variables),
m_version(version) {} m_version(version) {}
OPENVINO_SUPPRESS_DEPRECATED_END
void on_adapter(const std::string& name, ov::ValueAccessor<std::string>& value) override { void on_adapter(const std::string& name, ov::ValueAccessor<std::string>& value) override {
std::string val; std::string val;
@ -164,14 +162,12 @@ private:
// TODO consider to call only once per layer/TI-Loop node // TODO consider to call only once per layer/TI-Loop node
IoMap updated_io_map(const pugi::xml_node& node, const pugi::xml_node& body_node); IoMap updated_io_map(const pugi::xml_node& node, const pugi::xml_node& body_node);
OPENVINO_SUPPRESS_DEPRECATED_START
/// \brief Traverses xml node representation in order to create ov function for it. /// \brief Traverses xml node representation in order to create ov function for it.
/// \param node xml node representation /// \param node xml node representation
/// \param weights weights attached to current node /// \param weights weights attached to current node
/// \return shared pointer to function representing input node /// \return shared pointer to function representing input node
std::shared_ptr<ov::Model> parse_function(const pugi::xml_node& root, std::shared_ptr<ov::Model> parse_function(const pugi::xml_node& root,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights); const std::shared_ptr<ov::AlignedBuffer>& weights);
OPENVINO_SUPPRESS_DEPRECATED_END
/// \brief Traverses xml node representation in order to get the purpose attribute of /// \brief Traverses xml node representation in order to get the purpose attribute of
/// inputs/outputs in the body of Loop op. \param node xml node representation \return struct /// inputs/outputs in the body of Loop op. \param node xml node representation \return struct
/// with value of purpuse attribute /// with value of purpuse attribute
@ -179,12 +175,10 @@ private:
GenericLayerParams parse_generic_params(const pugi::xml_node& node); GenericLayerParams parse_generic_params(const pugi::xml_node& node);
OPENVINO_SUPPRESS_DEPRECATED_START
std::shared_ptr<ov::Node> create_node(const ov::OutputVector& inputs, std::shared_ptr<ov::Node> create_node(const ov::OutputVector& inputs,
const pugi::xml_node& node, const pugi::xml_node& node,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights, const std::shared_ptr<ov::AlignedBuffer>& weights,
const GenericLayerParams& params); const GenericLayerParams& params);
OPENVINO_SUPPRESS_DEPRECATED_END
void read_meta_data(const std::shared_ptr<ov::Model>& model, const pugi::xml_node& meta_section); void read_meta_data(const std::shared_ptr<ov::Model>& model, const pugi::xml_node& meta_section);
@ -194,9 +188,7 @@ private:
// -- DATA -- // -- DATA --
const pugi::xml_node m_node; const pugi::xml_node m_node;
OPENVINO_SUPPRESS_DEPRECATED_START const std::shared_ptr<ov::AlignedBuffer>& m_weights;
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& m_weights;
OPENVINO_SUPPRESS_DEPRECATED_END
const std::unordered_map<std::string, ov::OpSet>& m_opsets; const std::unordered_map<std::string, ov::OpSet>& m_opsets;
const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& m_extensions; const std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& m_extensions;
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& m_variables; std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& m_variables;

View File

@ -15,6 +15,7 @@
#include "ngraph/shape.hpp" #include "ngraph/shape.hpp"
#include "ngraph/type/element_type.hpp" #include "ngraph/type/element_type.hpp"
#include "onnx_common/utils.hpp" #include "onnx_common/utils.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "utils/common.hpp" #include "utils/common.hpp"
#include "utils/tensor_external_data.hpp" #include "utils/tensor_external_data.hpp"
@ -302,15 +303,13 @@ private:
template <typename T> template <typename T>
std::vector<T> get_external_data() const { std::vector<T> get_external_data() const {
const auto ext_data = detail::TensorExternalData(*m_tensor_proto); const auto ext_data = detail::TensorExternalData(*m_tensor_proto);
OPENVINO_SUPPRESS_DEPRECATED_START std::shared_ptr<ov::AlignedBuffer> buffer = nullptr;
std::shared_ptr<ngraph::runtime::AlignedBuffer> buffer = nullptr;
if (m_mmap_cache) { if (m_mmap_cache) {
buffer = ext_data.load_external_mmap_data(m_model_dir, m_mmap_cache); buffer = ext_data.load_external_mmap_data(m_model_dir, m_mmap_cache);
} else { } else {
buffer = ext_data.load_external_data(m_model_dir); buffer = ext_data.load_external_data(m_model_dir);
} }
return std::vector<T>(buffer->get_ptr<char>(), buffer->get_ptr<char>() + buffer->size()); return std::vector<T>(buffer->get_ptr<char>(), buffer->get_ptr<char>() + buffer->size());
OPENVINO_SUPPRESS_DEPRECATED_END
} }
const void* get_data_ptr() const { const void* get_data_ptr() const {

View File

@ -12,7 +12,6 @@
#include "openvino/util/file_util.hpp" #include "openvino/util/file_util.hpp"
#include "openvino/util/log.hpp" #include "openvino/util/log.hpp"
OPENVINO_SUPPRESS_DEPRECATED_START
namespace ngraph { namespace ngraph {
namespace onnx_import { namespace onnx_import {
namespace detail { namespace detail {
@ -51,13 +50,13 @@ Buffer<ov::MappedMemory> TensorExternalData::load_external_mmap_data(const std::
if (m_data_length > mapped_memory->size() || mapped_memory->size() == 0) { if (m_data_length > mapped_memory->size() || mapped_memory->size() == 0) {
throw error::invalid_external_data{*this}; throw error::invalid_external_data{*this};
} }
return std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>( return std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::MappedMemory>>>(
mapped_memory->data() + m_offset, mapped_memory->data() + m_offset,
m_data_length > 0 ? m_data_length : static_cast<uint64_t>(file_size) - m_offset, m_data_length > 0 ? m_data_length : static_cast<uint64_t>(file_size) - m_offset,
mapped_memory); mapped_memory);
} }
Buffer<ngraph::runtime::AlignedBuffer> TensorExternalData::load_external_data(const std::string& model_dir) const { Buffer<ov::AlignedBuffer> TensorExternalData::load_external_data(const std::string& model_dir) const {
auto full_path = ov::util::path_join({model_dir, m_data_location}); auto full_path = ov::util::path_join({model_dir, m_data_location});
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32) #if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
NGRAPH_SUPPRESS_DEPRECATED_START NGRAPH_SUPPRESS_DEPRECATED_START
@ -82,12 +81,11 @@ Buffer<ngraph::runtime::AlignedBuffer> TensorExternalData::load_external_data(co
// default value of m_offset is 0 // default value of m_offset is 0
external_data_stream.seekg(m_offset, std::ios::beg); external_data_stream.seekg(m_offset, std::ios::beg);
auto read_data = std::make_shared<ngraph::runtime::AlignedBuffer>(read_data_length); auto read_data = std::make_shared<ov::AlignedBuffer>(read_data_length);
external_data_stream.read(read_data->get_ptr<char>(), read_data_length); external_data_stream.read(read_data->get_ptr<char>(), read_data_length);
external_data_stream.close(); external_data_stream.close();
auto buffer = std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>( auto buffer = std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(read_data->get_ptr<char>(),
read_data->get_ptr<char>(),
read_data->size(), read_data->size(),
read_data); read_data);

View File

@ -6,15 +6,15 @@
#include <onnx/onnx_pb.h> #include <onnx/onnx_pb.h>
#include "ngraph/runtime/shared_buffer.hpp" #include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/mmap_object.hpp" #include "openvino/util/mmap_object.hpp"
namespace ngraph { namespace ngraph {
namespace onnx_import { namespace onnx_import {
namespace detail { namespace detail {
OPENVINO_SUPPRESS_DEPRECATED_START
template <class T> template <class T>
using Buffer = std::shared_ptr<ngraph::runtime::SharedBuffer<std::shared_ptr<T>>>; using Buffer = std::shared_ptr<ov::SharedBuffer<std::shared_ptr<T>>>;
using MappedMemoryHandles = std::shared_ptr<std::map<std::string, std::shared_ptr<ov::MappedMemory>>>; using MappedMemoryHandles = std::shared_ptr<std::map<std::string, std::shared_ptr<ov::MappedMemory>>>;
/// \brief Helper class used to load tensor data from external files /// \brief Helper class used to load tensor data from external files
class TensorExternalData { class TensorExternalData {
@ -28,7 +28,7 @@ public:
/// the invalid_external_data exception is thrown. /// the invalid_external_data exception is thrown.
/// ///
/// \return External binary data loaded into the SharedBuffer /// \return External binary data loaded into the SharedBuffer
Buffer<ngraph::runtime::AlignedBuffer> load_external_data(const std::string& model_dir) const; Buffer<ov::AlignedBuffer> load_external_data(const std::string& model_dir) const;
/// \brief Map (mmap for lin, MapViewOfFile for win) external data from tensor passed to constructor /// \brief Map (mmap for lin, MapViewOfFile for win) external data from tensor passed to constructor
/// ///
@ -50,7 +50,6 @@ private:
uint64_t m_data_length = 0; uint64_t m_data_length = 0;
std::string m_sha1_digest{}; std::string m_sha1_digest{};
}; };
OPENVINO_SUPPRESS_DEPRECATED_END
} // namespace detail } // namespace detail
} // namespace onnx_import } // namespace onnx_import
} // namespace ngraph } // namespace ngraph

View File

@ -9,6 +9,7 @@
#include "input_model.hpp" #include "input_model.hpp"
#include "ngraph/runtime/shared_buffer.hpp" #include "ngraph/runtime/shared_buffer.hpp"
#include "openvino/opsets/opset8.hpp" #include "openvino/opsets/opset8.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/mmap_object.hpp" #include "openvino/util/mmap_object.hpp"
#include "ov_tensorflow/tensor_bundle.pb.h" #include "ov_tensorflow/tensor_bundle.pb.h"
@ -44,15 +45,12 @@ static std::shared_ptr<ov::Node> read_variable(std::shared_ptr<VariablesIndex> v
node, node,
static_cast<int64_t>(mapped_memory->size()) >= entry.offset() + entry.size(), static_cast<int64_t>(mapped_memory->size()) >= entry.offset() + entry.size(),
"[TensorFlow Frontend] Internal error: Variable entry size is out of bounds of mapped memory size."); "[TensorFlow Frontend] Internal error: Variable entry size is out of bounds of mapped memory size.");
OPENVINO_SUPPRESS_DEPRECATED_START
return std::make_shared<Constant>( return std::make_shared<Constant>(
ov_type, ov_type,
shape, shape,
std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<MappedMemory>>>( std::make_shared<ov::SharedBuffer<std::shared_ptr<MappedMemory>>>(mapped_memory->data() + entry.offset(),
mapped_memory->data() + entry.offset(),
entry.size(), entry.size(),
mapped_memory)); mapped_memory));
OPENVINO_SUPPRESS_DEPRECATED_END
} else { } else {
std::vector<T> var_data; std::vector<T> var_data;
var_data.resize(size); var_data.resize(size);

View File

@ -20,6 +20,7 @@
#include "ie_icnn_network.hpp" #include "ie_icnn_network.hpp"
#include "ie_input_info.hpp" #include "ie_input_info.hpp"
#include "openvino/frontend/manager.hpp" #include "openvino/frontend/manager.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#ifdef ENABLE_IR_V7_READER #ifdef ENABLE_IR_V7_READER
# include "legacy/ie_ir_version.hpp" # include "legacy/ie_ir_version.hpp"
#endif #endif
@ -388,8 +389,8 @@ CNNNetwork details::ReadNetwork(const std::string& model,
ov::AnyVector params{&modelStream}; ov::AnyVector params{&modelStream};
if (weights) { if (weights) {
char* data = weights->cbuffer().as<char*>(); char* data = weights->cbuffer().as<char*>();
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights_buffer = std::shared_ptr<ov::AlignedBuffer> weights_buffer =
std::make_shared<ngraph::runtime::SharedBuffer<Blob::CPtr>>(data, weights->byteSize(), weights); std::make_shared<ov::SharedBuffer<Blob::CPtr>>(data, weights->byteSize(), weights);
params.emplace_back(weights_buffer); params.emplace_back(weights_buffer);
} }

View File

@ -9,6 +9,8 @@
#include "openvino/core/model.hpp" #include "openvino/core/model.hpp"
#include "openvino/core/preprocess/pre_post_process.hpp" #include "openvino/core/preprocess/pre_post_process.hpp"
#include "openvino/frontend/manager.hpp" #include "openvino/frontend/manager.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "openvino/runtime/shared_buffer.hpp"
#include "openvino/util/file_util.hpp" #include "openvino/util/file_util.hpp"
#include "transformations/utils/utils.hpp" #include "transformations/utils/utils.hpp"
@ -155,8 +157,8 @@ std::shared_ptr<ov::Model> read_model(const std::string& model,
ov::AnyVector params{&modelStream}; ov::AnyVector params{&modelStream};
if (weights) { if (weights) {
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights_buffer = std::shared_ptr<ov::AlignedBuffer> weights_buffer =
std::make_shared<ngraph::runtime::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(weights.data()), std::make_shared<ov::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(weights.data()),
weights.get_byte_size(), weights.get_byte_size(),
weights); weights);
params.emplace_back(weights_buffer); params.emplace_back(weights_buffer);

View File

@ -51,6 +51,7 @@
#include "legacy/ngraph_ops/selu_ie.hpp" #include "legacy/ngraph_ops/selu_ie.hpp"
#include "legacy/ngraph_ops/tile_ie.hpp" #include "legacy/ngraph_ops/tile_ie.hpp"
#include "legacy/ngraph_ops/topk_ie.hpp" #include "legacy/ngraph_ops/topk_ie.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
#include "transformations/rt_info/fused_names_attribute.hpp" #include "transformations/rt_info/fused_names_attribute.hpp"
#include "transformations/rt_info/primitives_priority_attribute.hpp" #include "transformations/rt_info/primitives_priority_attribute.hpp"
#include "transformations/utils/utils.hpp" #include "transformations/utils/utils.hpp"
@ -475,6 +476,11 @@ void CNNLayerCreator::on_adapter(const std::string& name, ::ngraph::ValueAccesso
const auto data_beg = static_cast<char*>(a->get()->get_ptr()); const auto data_beg = static_cast<char*>(a->get()->get_ptr());
params[name] = std::string(data_beg, a->get()->size()); params[name] = std::string(data_beg, a->get()->size());
} }
} else if (auto a = ::ngraph::as_type<::ngraph::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
if (std::string(node->get_type_name()) != "Constant") {
const auto data_beg = static_cast<char*>(a->get()->get_ptr());
params[name] = std::string(data_beg, a->get()->size());
}
} else if (const auto& a = ngraph::as_type<ngraph::AttributeAdapter<ngraph::element::TypeVector>>(&adapter)) { } else if (const auto& a = ngraph::as_type<ngraph::AttributeAdapter<ngraph::element::TypeVector>>(&adapter)) {
const auto& attrs = a->get(); const auto& attrs = a->get();
params[name] = details::joinVec(attrs); params[name] = details::joinVec(attrs);

View File

@ -14,6 +14,7 @@
#include "openvino/op/loop.hpp" #include "openvino/op/loop.hpp"
#include "openvino/op/util/framework_node.hpp" #include "openvino/op/util/framework_node.hpp"
#include "openvino/op/util/sub_graph_base.hpp" #include "openvino/op/util/sub_graph_base.hpp"
#include "openvino/runtime/aligned_buffer.hpp"
class FunctionsComparator { class FunctionsComparator {
public: public:
@ -945,9 +946,7 @@ private:
template <typename AttrValue> template <typename AttrValue>
void verify(const std::string& name, const AttrValue& attr_value); void verify(const std::string& name, const AttrValue& attr_value);
OPENVINO_SUPPRESS_DEPRECATED_START void verify_mem_buf(const std::string& name, const std::shared_ptr<ov::AlignedBuffer>& buffer);
void verify_mem_buf(const std::string& name, const std::shared_ptr<ngraph::runtime::AlignedBuffer>& buffer);
OPENVINO_SUPPRESS_DEPRECATED_END
using ModelAccessor = ov::ValueAccessor<std::shared_ptr<ov::Model>>; using ModelAccessor = ov::ValueAccessor<std::shared_ptr<ov::Model>>;

View File

@ -895,7 +895,6 @@ void check_rt_info(const std::shared_ptr<ov::Model>& f) {
namespace attributes { namespace attributes {
namespace detail { namespace detail {
OPENVINO_SUPPRESS_DEPRECATED_START
void ReadAndStoreAttributes::on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) { void ReadAndStoreAttributes::on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) {
if (auto inputs = ov::as_type<ov::AttributeAdapter<SubGraphOpInputDescription>>(&adapter)) { if (auto inputs = ov::as_type<ov::AttributeAdapter<SubGraphOpInputDescription>>(&adapter)) {
insert(name, inputs->get()); insert(name, inputs->get());
@ -904,7 +903,7 @@ void ReadAndStoreAttributes::on_adapter(const std::string& name, ov::ValueAccess
} else if (ov::is_type<ov::AttributeAdapter<SpecialBodyPorts>>(&adapter)) { } else if (ov::is_type<ov::AttributeAdapter<SpecialBodyPorts>>(&adapter)) {
// drop comparison, no more info than port indexes which will be check in // drop comparison, no more info than port indexes which will be check in
// subgraph::compare_io // subgraph::compare_io
} else if (auto a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(&adapter)) { } else if (auto a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
const auto beg = static_cast<unsigned char*>(a->get()->get_ptr()); const auto beg = static_cast<unsigned char*>(a->get()->get_ptr());
const auto end = beg + a->get()->size(); const auto end = beg + a->get()->size();
insert(name, storage::MemoryChunk{storage::MemoryChunk::Data(beg, end)}); insert(name, storage::MemoryChunk{storage::MemoryChunk::Data(beg, end)});
@ -923,7 +922,6 @@ void ReadAndStoreAttributes::on_adapter(const std::string& name, ov::ValueAccess
adapter.get_type_info().name + "']"; adapter.get_type_info().name + "']";
} }
} }
OPENVINO_SUPPRESS_DEPRECATED_END
template <typename AttrValue> template <typename AttrValue>
void ReadAndCompareAttributes::verify(const std::string& name, const AttrValue& attr_value) { void ReadAndCompareAttributes::verify(const std::string& name, const AttrValue& attr_value) {
if (should_return()) { if (should_return()) {
@ -942,9 +940,8 @@ void ReadAndCompareAttributes::verify(const std::string& name, const AttrValue&
} }
} }
OPENVINO_SUPPRESS_DEPRECATED_START
void ReadAndCompareAttributes::verify_mem_buf(const std::string& name, void ReadAndCompareAttributes::verify_mem_buf(const std::string& name,
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& buffer) { const std::shared_ptr<ov::AlignedBuffer>& buffer) {
if (should_return()) { if (should_return()) {
return; return;
} }
@ -961,7 +958,6 @@ void ReadAndCompareAttributes::verify_mem_buf(const std::string& name,
return; return;
} }
} }
OPENVINO_SUPPRESS_DEPRECATED_END
void ReadAndCompareAttributes::verify_function(const std::string& name, ModelAccessor& adapter) { void ReadAndCompareAttributes::verify_function(const std::string& name, ModelAccessor& adapter) {
if (should_return()) { if (should_return()) {
@ -980,7 +976,6 @@ void ReadAndCompareAttributes::verify_function(const std::string& name, ModelAcc
} }
} }
OPENVINO_SUPPRESS_DEPRECATED_START
void ReadAndCompareAttributes::verify_others(const std::string& name, ov::ValueAccessor<void>& adapter) { void ReadAndCompareAttributes::verify_others(const std::string& name, ov::ValueAccessor<void>& adapter) {
if (auto inputs = ov::as_type<ov::AttributeAdapter<SubGraphOpInputDescription>>(&adapter)) { if (auto inputs = ov::as_type<ov::AttributeAdapter<SubGraphOpInputDescription>>(&adapter)) {
verify(name, inputs->get()); verify(name, inputs->get());
@ -989,7 +984,7 @@ void ReadAndCompareAttributes::verify_others(const std::string& name, ov::ValueA
} else if (ov::is_type<ov::AttributeAdapter<SpecialBodyPorts>>(&adapter)) { } else if (ov::is_type<ov::AttributeAdapter<SpecialBodyPorts>>(&adapter)) {
// drop comparison, no more info than port indexes which will be check in // drop comparison, no more info than port indexes which will be check in
// subgraph::compare_io // subgraph::compare_io
} else if (auto a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(&adapter)) { } else if (auto a = ov::as_type<ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
verify_mem_buf(name, a->get()); verify_mem_buf(name, a->get());
} else if (auto attrs = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) { } else if (auto attrs = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) {
verify(name, attrs->get()); verify(name, attrs->get());
@ -1005,7 +1000,6 @@ void ReadAndCompareAttributes::verify_others(const std::string& name, ov::ValueA
adapter.get_type_info().name + "']"; adapter.get_type_info().name + "']";
} }
} }
OPENVINO_SUPPRESS_DEPRECATED_END
} // namespace detail } // namespace detail