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:
parent
84a0994ec5
commit
7ceff55b71
@ -8,6 +8,7 @@
|
||||
|
||||
#include "Python.h"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/runtime/shared_buffer.hpp"
|
||||
#include "openvino/util/common_util.hpp"
|
||||
|
||||
#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()));
|
||||
}
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
template <>
|
||||
ov::op::v0::Constant create_shared(py::array& array) {
|
||||
// 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 (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)),
|
||||
array.ndim() == 0 ? array.itemsize() : array.nbytes(),
|
||||
array);
|
||||
@ -185,7 +185,6 @@ ov::op::v0::Constant create_shared(py::array& array) {
|
||||
// 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_SUPPRESS_DEPRECATED_END
|
||||
|
||||
template <>
|
||||
ov::op::v0::Constant create_shared(ov::Tensor& tensor) {
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/op/util/framework_node.hpp"
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "transformations/rt_info/primitives_priority_attribute.hpp"
|
||||
|
||||
namespace ov {
|
||||
@ -180,6 +181,17 @@ public:
|
||||
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)) {
|
||||
const auto& attrs = a->get();
|
||||
// Update node attributes in data field
|
||||
|
75
src/core/dev_api/openvino/runtime/aligned_buffer.hpp
Normal file
75
src/core/dev_api/openvino/runtime/aligned_buffer.hpp
Normal 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
|
31
src/core/dev_api/openvino/runtime/shared_buffer.hpp
Normal file
31
src/core/dev_api/openvino/runtime/shared_buffer.hpp
Normal 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
|
@ -30,7 +30,6 @@ struct NGRAPH_API_DEPRECATED oi_pair {
|
||||
};
|
||||
|
||||
/// \brief Base class for annotations added to graph ops
|
||||
|
||||
class NGRAPH_API_DEPRECATED NGRAPH_API OpAnnotations {
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
public:
|
||||
|
@ -38,6 +38,7 @@ namespace ngraph {
|
||||
//
|
||||
// A SlicePlan is used to collect parameters for these ops.
|
||||
//
|
||||
// This class is moved to dev API
|
||||
struct NGRAPH_API_DEPRECATED NGRAPH_API SlicePlan {
|
||||
// Parameters for the Slice
|
||||
std::vector<int64_t> begins;
|
||||
|
@ -31,9 +31,7 @@ namespace ngraph {
|
||||
class NGRAPH_API OpSet : public ov::OpSet {
|
||||
public:
|
||||
explicit OpSet(const ov::OpSet& opset);
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
OpSet(const ngraph::OpSet& opset);
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
OpSet() = default;
|
||||
/// \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) {
|
||||
@ -56,19 +54,20 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
const NGRAPH_API OpSet& get_opset1();
|
||||
const NGRAPH_API OpSet& get_opset2();
|
||||
const NGRAPH_API OpSet& get_opset3();
|
||||
const NGRAPH_API OpSet& get_opset4();
|
||||
const NGRAPH_API OpSet& get_opset5();
|
||||
const NGRAPH_API OpSet& get_opset6();
|
||||
const NGRAPH_API OpSet& get_opset7();
|
||||
const NGRAPH_API OpSet& get_opset8();
|
||||
const NGRAPH_API OpSet& get_opset9();
|
||||
const NGRAPH_API OpSet& get_opset10();
|
||||
const NGRAPH_API OpSet& get_opset11();
|
||||
const NGRAPH_API OpSet& get_opset12();
|
||||
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 OpSet& get_opset1();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset2();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset3();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset4();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset5();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset6();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset7();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset8();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset9();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset10();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset11();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset12();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API OpSet& get_opset13();
|
||||
NGRAPH_API_DEPRECATED const NGRAPH_API std::map<std::string, std::function<const ngraph::OpSet&()>>&
|
||||
get_available_opsets();
|
||||
} // namespace ngraph
|
||||
NGRAPH_SUPPRESS_DEPRECATED_END
|
||||
|
@ -12,7 +12,6 @@
|
||||
# define WAS_OV_LIBRARY_DEFINED_CONSTANT
|
||||
#endif
|
||||
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "ngraph/runtime/host_tensor.hpp"
|
||||
#include "ngraph/runtime/shared_buffer.hpp"
|
||||
|
||||
@ -21,11 +20,14 @@
|
||||
# undef WAS_OV_LIBRARY_DEFINED_CONSTANT
|
||||
#endif
|
||||
#include "openvino/core/coordinate_diff.hpp"
|
||||
#include "openvino/core/node.hpp"
|
||||
#include "openvino/core/type/element_type.hpp"
|
||||
#include "openvino/core/type/element_type_traits.hpp"
|
||||
#include "openvino/op/op.hpp"
|
||||
|
||||
namespace ov {
|
||||
|
||||
class AlignedBuffer;
|
||||
|
||||
namespace op {
|
||||
namespace v0 {
|
||||
/// \brief Class for constants.
|
||||
@ -177,13 +179,20 @@ public:
|
||||
/// \param shape The shape of the tensor constant.
|
||||
/// \param data A pointer to pre-allocated shared data.
|
||||
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)
|
||||
: 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_shape(shape) {
|
||||
m_data = data;
|
||||
constructor_validate_and_infer_types();
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
Constant(const Constant& other);
|
||||
Constant(const Constant& other, const Shape& new_shape);
|
||||
@ -241,11 +250,7 @@ public:
|
||||
AxisSet get_axis_set_val() const;
|
||||
|
||||
/// \brief Return data size in bytes
|
||||
size_t get_byte_size() const {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
return m_data->size();
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
size_t get_byte_size() const;
|
||||
|
||||
/// \brief Wrapper around constructing a shared_ptr of a Constant
|
||||
///
|
||||
@ -370,11 +375,8 @@ public:
|
||||
return rc;
|
||||
}
|
||||
|
||||
const void* get_data_ptr() const {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
return (m_data ? m_data->get_ptr() : nullptr);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
const void* get_data_ptr() const;
|
||||
|
||||
template <typename T>
|
||||
const T* get_data_ptr() const {
|
||||
OPENVINO_ASSERT(sizeof(T) <= m_element_type.size() || shape_size(m_shape) <= 0, "Buffer over-read");
|
||||
@ -406,6 +408,11 @@ public:
|
||||
private:
|
||||
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,
|
||||
typename StorageDataType = fundamental_type_for<Type>,
|
||||
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* get_data_ptr_nc() {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
return (m_data ? m_data->get_ptr() : nullptr);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
void* get_data_ptr_nc();
|
||||
|
||||
template <element::Type_t ET>
|
||||
typename element_type_traits<ET>::value_type* get_data_ptr_nc() {
|
||||
@ -853,9 +856,7 @@ private:
|
||||
|
||||
element::Type m_element_type;
|
||||
Shape m_shape{};
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer> m_data;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
std::shared_ptr<ov::AlignedBuffer> m_data;
|
||||
mutable std::atomic_bool m_all_elements_bitwise_identical{false};
|
||||
mutable std::atomic_bool m_all_elements_bitwise_identical_checked{false};
|
||||
bool m_alloc_buffer_on_visit_attributes = true;
|
||||
|
@ -8,10 +8,10 @@
|
||||
|
||||
#include <cmath>
|
||||
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/reference/reshape.hpp"
|
||||
#include "openvino/reference/reverse.hpp"
|
||||
#include "openvino/reference/slice.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace reference {
|
||||
@ -30,8 +30,7 @@ void strided_slice(const char* arg,
|
||||
return;
|
||||
}
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
ngraph::runtime::AlignedBuffer slice_out_buffer(shape_size(sp.reshape_in_shape) * elem_type);
|
||||
ov::AlignedBuffer slice_out_buffer(shape_size(sp.reshape_in_shape) * elem_type);
|
||||
slice(reinterpret_cast<const char*>(arg),
|
||||
slice_out_buffer.get_ptr<char>(),
|
||||
arg_shape,
|
||||
@ -41,7 +40,7 @@ void strided_slice(const char* arg,
|
||||
sp.reshape_in_shape,
|
||||
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);
|
||||
|
||||
reverse(reshape_out_buffer.get_ptr<char>(),
|
||||
@ -50,7 +49,6 @@ void strided_slice(const char* arg,
|
||||
sp.reshape_out_shape,
|
||||
sp.reverse_axes,
|
||||
elem_type);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
} // namespace reference
|
||||
} // namespace ov
|
||||
|
@ -10,8 +10,10 @@
|
||||
#include <sstream>
|
||||
|
||||
#include "itt.hpp"
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "ngraph/runtime/host_tensor.hpp"
|
||||
#include "ngraph/runtime/tensor.hpp"
|
||||
#include "openvino/runtime/shared_buffer.hpp"
|
||||
|
||||
template <typename T>
|
||||
static inline std::string to_cpp_string(T value) {
|
||||
@ -27,6 +29,14 @@ static inline std::string to_cpp_string(T value) {
|
||||
}
|
||||
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
|
||||
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
|
||||
// And copy data in other cas
|
||||
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()),
|
||||
tensor->get_size_in_bytes(),
|
||||
tensor);
|
||||
@ -51,12 +61,10 @@ OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
ov::op::v0::Constant::Constant(const ov::Tensor& tensor) {
|
||||
m_element_type = tensor.get_element_type();
|
||||
m_shape = tensor.get_shape();
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
// Share data from ov::Tensor
|
||||
m_data = std::make_shared<ngraph::runtime::SharedBuffer<ov::Tensor>>(static_cast<char*>(tensor.data()),
|
||||
tensor.get_byte_size(),
|
||||
tensor);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
m_data = std::make_shared<ov::SharedBuffer<ov::Tensor>>(static_cast<char*>(tensor.data()),
|
||||
tensor.get_byte_size(),
|
||||
tensor);
|
||||
|
||||
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) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
m_data = std::make_shared<ngraph::runtime::AlignedBuffer>(mem_size(), host_alignment());
|
||||
m_data = std::make_shared<ov::AlignedBuffer>(mem_size(), host_alignment());
|
||||
if (memset_allocation) {
|
||||
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)
|
||||
@ -316,6 +322,18 @@ std::string ov::op::v0::Constant::convert_value_to_string(size_t index) const {
|
||||
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> rc;
|
||||
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include "openvino/opsets/opset1.hpp"
|
||||
#include "openvino/pass/constant_folding.hpp"
|
||||
#include "openvino/reference/convert.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
#include "pugixml.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("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)) {
|
||||
const auto& attrs = a->get();
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include <memory>
|
||||
|
||||
#include "ngraph/util.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
@ -64,3 +65,53 @@ AttributeAdapter<std::shared_ptr<ngraph::runtime::AlignedBuffer>>::AttributeAdap
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer>& value)
|
||||
: DirectValueAccessor<std::shared_ptr<ngraph::runtime::AlignedBuffer>>(value) {}
|
||||
} // 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
|
||||
|
@ -2,31 +2,30 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
|
||||
#include "gtest/gtest.h"
|
||||
|
||||
using namespace ngraph;
|
||||
using namespace ov;
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
TEST(aligned_buffer, alignment) {
|
||||
runtime::AlignedBuffer buffer(100, 64);
|
||||
AlignedBuffer buffer(100, 64);
|
||||
size_t addr = reinterpret_cast<size_t>(buffer.get_ptr()) % 64;
|
||||
EXPECT_EQ(addr, 0);
|
||||
}
|
||||
|
||||
TEST(aligned_buffer, move) {
|
||||
{
|
||||
runtime::AlignedBuffer buffer1(100, 64);
|
||||
runtime::AlignedBuffer buffer2(std::move(buffer1));
|
||||
AlignedBuffer buffer1(100, 64);
|
||||
AlignedBuffer buffer2(std::move(buffer1));
|
||||
EXPECT_EQ(buffer1.size(), 0);
|
||||
EXPECT_EQ(buffer1.get_ptr(), nullptr);
|
||||
EXPECT_EQ(buffer2.size(), 100);
|
||||
EXPECT_NE(buffer2.get_ptr(), nullptr);
|
||||
}
|
||||
{
|
||||
runtime::AlignedBuffer buffer1(100, 64);
|
||||
runtime::AlignedBuffer buffer2;
|
||||
AlignedBuffer buffer1(100, 64);
|
||||
AlignedBuffer buffer2;
|
||||
buffer2 = std::move(buffer1);
|
||||
EXPECT_EQ(buffer1.size(), 0);
|
||||
EXPECT_EQ(buffer1.get_ptr(), nullptr);
|
||||
|
@ -10,7 +10,7 @@
|
||||
#include <random>
|
||||
|
||||
#include "common_test_utils/float_util.hpp"
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
using namespace std;
|
||||
@ -140,9 +140,8 @@ TEST(bfloat16, numeric_limits) {
|
||||
}
|
||||
|
||||
TEST(benchmark, bfloat16) {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
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());
|
||||
// vector<float> data(buffer_size);
|
||||
std::mt19937 rng(2112);
|
||||
@ -153,53 +152,36 @@ TEST(benchmark, bfloat16) {
|
||||
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());
|
||||
ngraph::stopwatch timer;
|
||||
timer.start();
|
||||
for (size_t i = 0; i < buffer_size; ++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());
|
||||
ngraph::stopwatch timer;
|
||||
timer.start();
|
||||
for (size_t i = 0; i < buffer_size; ++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());
|
||||
ngraph::stopwatch timer;
|
||||
timer.start();
|
||||
for (size_t i = 0; i < buffer_size; ++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());
|
||||
ngraph::stopwatch timer;
|
||||
timer.start();
|
||||
for (size_t i = 0; i < buffer_size; ++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) {
|
||||
|
@ -10,6 +10,8 @@
|
||||
|
||||
#include "common_test_utils/type_prop.hpp"
|
||||
#include "openvino/core/except.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/runtime/shared_buffer.hpp"
|
||||
|
||||
using namespace ov;
|
||||
using namespace std;
|
||||
@ -1726,14 +1728,12 @@ TEST(constant, lazy_bitwise_identical) {
|
||||
auto shape = Shape{10, 1000, 1000};
|
||||
auto type = element::i32;
|
||||
auto byte_size = shape_size(shape) * sizeof(int32_t);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
auto aligned_weights_buffer = std::make_shared<ngraph::runtime::AlignedBuffer>(byte_size);
|
||||
auto aligned_weights_buffer = std::make_shared<ov::AlignedBuffer>(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>>>(
|
||||
aligned_weights_buffer->get_ptr<char>(),
|
||||
aligned_weights_buffer->size(),
|
||||
aligned_weights_buffer);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
auto weights =
|
||||
std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(aligned_weights_buffer->get_ptr<char>(),
|
||||
aligned_weights_buffer->size(),
|
||||
aligned_weights_buffer);
|
||||
|
||||
using namespace std::chrono;
|
||||
auto create_constant = [&]() {
|
||||
|
@ -10,12 +10,13 @@
|
||||
#include <vector>
|
||||
|
||||
#include "ngraph/factory.hpp"
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/core/attribute_visitor.hpp"
|
||||
#include "openvino/core/deprecated.hpp"
|
||||
#include "openvino/op/util/framework_node.hpp"
|
||||
#include "openvino/op/util/sub_graph_base.hpp"
|
||||
#include "openvino/op/util/variable.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/runtime/tensor.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace test {
|
||||
@ -217,10 +218,9 @@ public:
|
||||
}
|
||||
|
||||
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<ngraph::runtime::AlignedBuffer>>>(&adapter)) {
|
||||
auto& data = m_values.get<ngraph::HostTensorPtr>(name);
|
||||
data->read(a->get()->get_ptr(), a->get()->size());
|
||||
if (auto a = ::ov::as_type<::ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
|
||||
auto& data = m_values.get<ov::Tensor>(name);
|
||||
std::memcpy(a->get()->get_ptr(), data.data(), a->get()->size());
|
||||
} else if (auto a = ov::as_type<
|
||||
ov::AttributeAdapter<std::vector<std::shared_ptr<ov::op::util::SubGraphOp::OutputDescription>>>>(
|
||||
&adapter)) {
|
||||
@ -240,7 +240,6 @@ public:
|
||||
} else {
|
||||
OPENVINO_THROW("Attribute \"", name, "\" cannot be unmarshalled");
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
// 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 {
|
||||
@ -309,10 +308,9 @@ public:
|
||||
}
|
||||
|
||||
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<ngraph::runtime::AlignedBuffer>>>(&adapter)) {
|
||||
ngraph::HostTensorPtr data = std::make_shared<ngraph::HostTensor>(element::u8, Shape{a->get()->size()});
|
||||
data->write(a->get()->get_ptr(), a->get()->size());
|
||||
if (auto a = ::ov::as_type<::ov::AttributeAdapter<std::shared_ptr<ov::AlignedBuffer>>>(&adapter)) {
|
||||
ov::Tensor data(element::u8, Shape{a->get()->size()});
|
||||
std::memcpy(data.data(), a->get()->get_ptr(), a->get()->size());
|
||||
m_values.insert(name, data);
|
||||
} else if (auto a = ov::as_type<
|
||||
ov::AttributeAdapter<std::vector<std::shared_ptr<ov::op::util::SubGraphOp::OutputDescription>>>>(
|
||||
@ -333,7 +331,6 @@ public:
|
||||
} else {
|
||||
OPENVINO_THROW("Attribute \"", name, "\" cannot be marshalled");
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
// 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 {
|
||||
|
@ -9,10 +9,10 @@
|
||||
#include <vector>
|
||||
|
||||
#include "input_model.hpp"
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "ngraph/runtime/shared_buffer.hpp"
|
||||
#include "openvino/core/any.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/mmap_object.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 {
|
||||
std::ifstream local_model_stream;
|
||||
std::istream* provided_model_stream = nullptr;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights;
|
||||
std::shared_ptr<ov::AlignedBuffer> weights;
|
||||
|
||||
auto create_extensions_map = [&]() -> std::unordered_map<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr> {
|
||||
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>()) {
|
||||
weights_path = variant.as<std::wstring>();
|
||||
#endif
|
||||
} else if (variant.is<std::shared_ptr<ngraph::runtime::AlignedBuffer>>()) {
|
||||
weights = variant.as<std::shared_ptr<ngraph::runtime::AlignedBuffer>>();
|
||||
} else if (variant.is<std::shared_ptr<ov::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;
|
||||
@ -204,10 +203,9 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
|
||||
if (!weights_path.empty()) {
|
||||
if (enable_mmap) {
|
||||
auto mapped_memory = ov::load_mmap_object(weights_path);
|
||||
weights =
|
||||
std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<MappedMemory>>>(mapped_memory->data(),
|
||||
mapped_memory->size(),
|
||||
mapped_memory);
|
||||
weights = std::make_shared<ov::SharedBuffer<std::shared_ptr<MappedMemory>>>(mapped_memory->data(),
|
||||
mapped_memory->size(),
|
||||
mapped_memory);
|
||||
} else {
|
||||
std::ifstream bin_stream;
|
||||
bin_stream.open(weights_path.c_str(), std::ios::binary);
|
||||
@ -222,17 +220,16 @@ InputModel::Ptr FrontEnd::load_impl(const std::vector<ov::Any>& variants) const
|
||||
size_t file_size = bin_stream.tellg();
|
||||
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.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->size(),
|
||||
aligned_weights_buffer);
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
return create_input_model();
|
||||
}
|
||||
|
@ -18,10 +18,9 @@
|
||||
#include "openvino/util/common_util.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace {
|
||||
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) {
|
||||
/* 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;
|
||||
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));
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
OPENVINO_ASSERT(const_node);
|
||||
const auto& consumers = input_node->output(0).get_target_inputs();
|
||||
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
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
namespace ov {
|
||||
namespace frontend {
|
||||
namespace ir {
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
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<std::string, ov::OpSet> m_opsets;
|
||||
pugi::xml_node m_root;
|
||||
@ -209,7 +208,7 @@ class InputModel::InputModelIRImpl {
|
||||
|
||||
public:
|
||||
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)
|
||||
: m_weights(weights),
|
||||
m_extensions(extensions) {
|
||||
@ -227,11 +226,10 @@ public:
|
||||
};
|
||||
|
||||
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) {
|
||||
_impl = std::make_shared<InputModelIRImpl>(stream, weights, extensions);
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
std::shared_ptr<ov::Model> InputModel::convert() {
|
||||
return _impl->convert();
|
||||
|
@ -7,9 +7,9 @@
|
||||
#include <istream>
|
||||
#include <memory>
|
||||
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/frontend/manager.hpp"
|
||||
#include "openvino/frontend/visibility.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
|
||||
namespace ov {
|
||||
namespace frontend {
|
||||
@ -20,11 +20,9 @@ class InputModel : public ov::frontend::InputModel {
|
||||
std::shared_ptr<InputModelIRImpl> _impl;
|
||||
|
||||
public:
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
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);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
std::shared_ptr<Model> convert();
|
||||
};
|
||||
|
@ -20,6 +20,8 @@
|
||||
#include "openvino/op/util/read_value_base.hpp"
|
||||
#include "openvino/op/util/sub_graph_base.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 "transformations/rt_info/attributes.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))
|
||||
return;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
if (auto a = ov::as_type<ov::AttributeAdapter<ov::element::Type>>(&adapter)) {
|
||||
static_cast<ov::element::Type&>(*a) = ov::element::Type(val);
|
||||
} 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});
|
||||
}
|
||||
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;
|
||||
pugi::xml_node dn = m_node.child("data");
|
||||
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!");
|
||||
|
||||
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());
|
||||
value.copy(data, value.size());
|
||||
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!");
|
||||
|
||||
char* data = m_weights->get_ptr<char>() + offset;
|
||||
auto buffer =
|
||||
std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(
|
||||
data,
|
||||
size,
|
||||
m_weights);
|
||||
auto buffer = std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(data, size, m_weights);
|
||||
a->set(buffer);
|
||||
}
|
||||
} 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 {
|
||||
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) {
|
||||
@ -409,10 +405,8 @@ void ov::XmlDeserializer::on_adapter(const std::string& name, ov::ValueAccessor<
|
||||
adapter.set(model);
|
||||
}
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::shared_ptr<ov::Model> ov::XmlDeserializer::parse_function(
|
||||
const pugi::xml_node& root,
|
||||
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights) {
|
||||
std::shared_ptr<ov::Model> ov::XmlDeserializer::parse_function(const pugi::xml_node& root,
|
||||
const std::shared_ptr<ov::AlignedBuffer>& weights) {
|
||||
// OV_ITT_SCOPE_CHAIN(FIRST_INFERENCE, taskChain, itt::domains::V10Reader_RT, "V10Parser", "Parse");
|
||||
|
||||
struct FunctionNodes {
|
||||
@ -553,7 +547,6 @@ std::shared_ptr<ov::Model> ov::XmlDeserializer::parse_function(
|
||||
|
||||
return function;
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
class MetaDataParser : public ov::Meta {
|
||||
public:
|
||||
@ -751,12 +744,10 @@ static const std::string& translate_type_name(const std::string& name) {
|
||||
return name;
|
||||
}
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(
|
||||
const std::vector<ov::Output<ov::Node>>& inputs,
|
||||
const pugi::xml_node& node,
|
||||
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights,
|
||||
const GenericLayerParams& params) {
|
||||
std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(const std::vector<ov::Output<ov::Node>>& inputs,
|
||||
const pugi::xml_node& node,
|
||||
const std::shared_ptr<ov::AlignedBuffer>& weights,
|
||||
const GenericLayerParams& params) {
|
||||
// Check that inputs are correctly defined
|
||||
for (size_t i = 0; i < inputs.size(); i++) {
|
||||
if (!inputs[i].get_node())
|
||||
@ -959,4 +950,3 @@ std::shared_ptr<ov::Node> ov::XmlDeserializer::create_node(
|
||||
|
||||
return ovNode;
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
@ -10,11 +10,11 @@
|
||||
#include <pugixml.hpp>
|
||||
|
||||
#include "input_model.hpp"
|
||||
#include "ngraph/runtime/aligned_buffer.hpp"
|
||||
#include "openvino/core/attribute_visitor.hpp"
|
||||
#include "openvino/core/op_extension.hpp"
|
||||
#include "openvino/op/loop.hpp"
|
||||
#include "openvino/op/util/sub_graph_base.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "utils.hpp"
|
||||
|
||||
namespace ov {
|
||||
@ -58,9 +58,8 @@ struct GenericLayerParams {
|
||||
|
||||
class XmlDeserializer : public ov::AttributeVisitor {
|
||||
public:
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
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<ov::DiscreteTypeInfo, ov::BaseOpExtension::Ptr>& extensions,
|
||||
std::unordered_map<std::string, std::shared_ptr<ov::op::util::Variable>>& variables,
|
||||
@ -71,7 +70,6 @@ public:
|
||||
m_extensions(extensions),
|
||||
m_variables(variables),
|
||||
m_version(version) {}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
void on_adapter(const std::string& name, ov::ValueAccessor<std::string>& value) override {
|
||||
std::string val;
|
||||
@ -164,14 +162,12 @@ private:
|
||||
// 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);
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
/// \brief Traverses xml node representation in order to create ov function for it.
|
||||
/// \param node xml node representation
|
||||
/// \param weights weights attached to current node
|
||||
/// \return shared pointer to function representing input node
|
||||
std::shared_ptr<ov::Model> parse_function(const pugi::xml_node& root,
|
||||
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
const std::shared_ptr<ov::AlignedBuffer>& weights);
|
||||
/// \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
|
||||
/// with value of purpuse attribute
|
||||
@ -179,12 +175,10 @@ private:
|
||||
|
||||
GenericLayerParams parse_generic_params(const pugi::xml_node& node);
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::shared_ptr<ov::Node> create_node(const ov::OutputVector& inputs,
|
||||
const pugi::xml_node& node,
|
||||
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& weights,
|
||||
const std::shared_ptr<ov::AlignedBuffer>& weights,
|
||||
const GenericLayerParams& params);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
void read_meta_data(const std::shared_ptr<ov::Model>& model, const pugi::xml_node& meta_section);
|
||||
|
||||
@ -194,9 +188,7 @@ private:
|
||||
|
||||
// -- DATA --
|
||||
const pugi::xml_node m_node;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& m_weights;
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
const std::shared_ptr<ov::AlignedBuffer>& m_weights;
|
||||
const std::unordered_map<std::string, ov::OpSet>& m_opsets;
|
||||
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;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "ngraph/shape.hpp"
|
||||
#include "ngraph/type/element_type.hpp"
|
||||
#include "onnx_common/utils.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
#include "utils/common.hpp"
|
||||
#include "utils/tensor_external_data.hpp"
|
||||
|
||||
@ -302,15 +303,13 @@ private:
|
||||
template <typename T>
|
||||
std::vector<T> get_external_data() const {
|
||||
const auto ext_data = detail::TensorExternalData(*m_tensor_proto);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer> buffer = nullptr;
|
||||
std::shared_ptr<ov::AlignedBuffer> buffer = nullptr;
|
||||
if (m_mmap_cache) {
|
||||
buffer = ext_data.load_external_mmap_data(m_model_dir, m_mmap_cache);
|
||||
} else {
|
||||
buffer = ext_data.load_external_data(m_model_dir);
|
||||
}
|
||||
return std::vector<T>(buffer->get_ptr<char>(), buffer->get_ptr<char>() + buffer->size());
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
}
|
||||
|
||||
const void* get_data_ptr() const {
|
||||
|
@ -12,7 +12,6 @@
|
||||
#include "openvino/util/file_util.hpp"
|
||||
#include "openvino/util/log.hpp"
|
||||
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
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) {
|
||||
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,
|
||||
m_data_length > 0 ? m_data_length : static_cast<uint64_t>(file_size) - m_offset,
|
||||
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});
|
||||
#if defined(OPENVINO_ENABLE_UNICODE_PATH_SUPPORT) && defined(_WIN32)
|
||||
NGRAPH_SUPPRESS_DEPRECATED_START
|
||||
@ -82,14 +81,13 @@ Buffer<ngraph::runtime::AlignedBuffer> TensorExternalData::load_external_data(co
|
||||
// default value of m_offset is 0
|
||||
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.close();
|
||||
|
||||
auto buffer = std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<ngraph::runtime::AlignedBuffer>>>(
|
||||
read_data->get_ptr<char>(),
|
||||
read_data->size(),
|
||||
read_data);
|
||||
auto buffer = std::make_shared<ov::SharedBuffer<std::shared_ptr<ov::AlignedBuffer>>>(read_data->get_ptr<char>(),
|
||||
read_data->size(),
|
||||
read_data);
|
||||
|
||||
return buffer;
|
||||
}
|
||||
|
@ -6,15 +6,15 @@
|
||||
|
||||
#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"
|
||||
|
||||
namespace ngraph {
|
||||
namespace onnx_import {
|
||||
namespace detail {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
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>>>;
|
||||
/// \brief Helper class used to load tensor data from external files
|
||||
class TensorExternalData {
|
||||
@ -28,7 +28,7 @@ public:
|
||||
/// the invalid_external_data exception is thrown.
|
||||
///
|
||||
/// \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
|
||||
///
|
||||
@ -50,7 +50,6 @@ private:
|
||||
uint64_t m_data_length = 0;
|
||||
std::string m_sha1_digest{};
|
||||
};
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
} // namespace detail
|
||||
} // namespace onnx_import
|
||||
} // namespace ngraph
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "input_model.hpp"
|
||||
#include "ngraph/runtime/shared_buffer.hpp"
|
||||
#include "openvino/opsets/opset8.hpp"
|
||||
#include "openvino/runtime/shared_buffer.hpp"
|
||||
#include "openvino/util/mmap_object.hpp"
|
||||
#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,
|
||||
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.");
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
return std::make_shared<Constant>(
|
||||
ov_type,
|
||||
shape,
|
||||
std::make_shared<ngraph::runtime::SharedBuffer<std::shared_ptr<MappedMemory>>>(
|
||||
mapped_memory->data() + entry.offset(),
|
||||
entry.size(),
|
||||
mapped_memory));
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
std::make_shared<ov::SharedBuffer<std::shared_ptr<MappedMemory>>>(mapped_memory->data() + entry.offset(),
|
||||
entry.size(),
|
||||
mapped_memory));
|
||||
} else {
|
||||
std::vector<T> var_data;
|
||||
var_data.resize(size);
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "ie_icnn_network.hpp"
|
||||
#include "ie_input_info.hpp"
|
||||
#include "openvino/frontend/manager.hpp"
|
||||
#include "openvino/runtime/shared_buffer.hpp"
|
||||
#ifdef ENABLE_IR_V7_READER
|
||||
# include "legacy/ie_ir_version.hpp"
|
||||
#endif
|
||||
@ -388,8 +389,8 @@ CNNNetwork details::ReadNetwork(const std::string& model,
|
||||
ov::AnyVector params{&modelStream};
|
||||
if (weights) {
|
||||
char* data = weights->cbuffer().as<char*>();
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights_buffer =
|
||||
std::make_shared<ngraph::runtime::SharedBuffer<Blob::CPtr>>(data, weights->byteSize(), weights);
|
||||
std::shared_ptr<ov::AlignedBuffer> weights_buffer =
|
||||
std::make_shared<ov::SharedBuffer<Blob::CPtr>>(data, weights->byteSize(), weights);
|
||||
params.emplace_back(weights_buffer);
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include "openvino/core/model.hpp"
|
||||
#include "openvino/core/preprocess/pre_post_process.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 "transformations/utils/utils.hpp"
|
||||
|
||||
@ -155,10 +157,10 @@ std::shared_ptr<ov::Model> read_model(const std::string& model,
|
||||
|
||||
ov::AnyVector params{&modelStream};
|
||||
if (weights) {
|
||||
std::shared_ptr<ngraph::runtime::AlignedBuffer> weights_buffer =
|
||||
std::make_shared<ngraph::runtime::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(weights.data()),
|
||||
weights.get_byte_size(),
|
||||
weights);
|
||||
std::shared_ptr<ov::AlignedBuffer> weights_buffer =
|
||||
std::make_shared<ov::SharedBuffer<ov::Tensor>>(reinterpret_cast<char*>(weights.data()),
|
||||
weights.get_byte_size(),
|
||||
weights);
|
||||
params.emplace_back(weights_buffer);
|
||||
}
|
||||
|
||||
|
@ -51,6 +51,7 @@
|
||||
#include "legacy/ngraph_ops/selu_ie.hpp"
|
||||
#include "legacy/ngraph_ops/tile_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/primitives_priority_attribute.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());
|
||||
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)) {
|
||||
const auto& attrs = a->get();
|
||||
params[name] = details::joinVec(attrs);
|
||||
|
@ -14,6 +14,7 @@
|
||||
#include "openvino/op/loop.hpp"
|
||||
#include "openvino/op/util/framework_node.hpp"
|
||||
#include "openvino/op/util/sub_graph_base.hpp"
|
||||
#include "openvino/runtime/aligned_buffer.hpp"
|
||||
|
||||
class FunctionsComparator {
|
||||
public:
|
||||
@ -945,9 +946,7 @@ private:
|
||||
template <typename AttrValue>
|
||||
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<ngraph::runtime::AlignedBuffer>& buffer);
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
void verify_mem_buf(const std::string& name, const std::shared_ptr<ov::AlignedBuffer>& buffer);
|
||||
|
||||
using ModelAccessor = ov::ValueAccessor<std::shared_ptr<ov::Model>>;
|
||||
|
||||
|
@ -895,7 +895,6 @@ void check_rt_info(const std::shared_ptr<ov::Model>& f) {
|
||||
|
||||
namespace attributes {
|
||||
namespace detail {
|
||||
OPENVINO_SUPPRESS_DEPRECATED_START
|
||||
void ReadAndStoreAttributes::on_adapter(const std::string& name, ov::ValueAccessor<void>& adapter) {
|
||||
if (auto inputs = ov::as_type<ov::AttributeAdapter<SubGraphOpInputDescription>>(&adapter)) {
|
||||
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)) {
|
||||
// drop comparison, no more info than port indexes which will be check in
|
||||
// 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 end = beg + a->get()->size();
|
||||
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 + "']";
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
template <typename AttrValue>
|
||||
void ReadAndCompareAttributes::verify(const std::string& name, const AttrValue& attr_value) {
|
||||
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,
|
||||
const std::shared_ptr<ngraph::runtime::AlignedBuffer>& buffer) {
|
||||
const std::shared_ptr<ov::AlignedBuffer>& buffer) {
|
||||
if (should_return()) {
|
||||
return;
|
||||
}
|
||||
@ -961,7 +958,6 @@ void ReadAndCompareAttributes::verify_mem_buf(const std::string& name,
|
||||
return;
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
void ReadAndCompareAttributes::verify_function(const std::string& name, ModelAccessor& adapter) {
|
||||
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) {
|
||||
if (auto inputs = ov::as_type<ov::AttributeAdapter<SubGraphOpInputDescription>>(&adapter)) {
|
||||
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)) {
|
||||
// drop comparison, no more info than port indexes which will be check in
|
||||
// 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());
|
||||
} else if (auto attrs = ov::as_type<ov::AttributeAdapter<ov::op::util::FrameworkNodeAttrs>>(&adapter)) {
|
||||
verify(name, attrs->get());
|
||||
@ -1005,7 +1000,6 @@ void ReadAndCompareAttributes::verify_others(const std::string& name, ov::ValueA
|
||||
adapter.get_type_info().name + "']";
|
||||
}
|
||||
}
|
||||
OPENVINO_SUPPRESS_DEPRECATED_END
|
||||
|
||||
} // namespace detail
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user