Skip to content

Commit

Permalink
Fixed C++ RTTI for Core base classes (#28555)
Browse files Browse the repository at this point in the history
Android support:

<img width="200" alt="{ABD03686-78FD-4F33-A2E8-C3BE1C030D5C}"
src="https://github.com/user-attachments/assets/55bb0600-4f14-448c-b4be-e1e97e354859"
/>

in header files threated as an inline definition, which typically
results in a "weak" symbol
"weak"  symbols are not exported from dll/so libs.

To make these symbols "strong", we moved the definitions to ".cpp"
files.
  • Loading branch information
ilya-lavrenov committed Jan 23, 2025
1 parent 6895e1a commit 1e9a7e8
Show file tree
Hide file tree
Showing 34 changed files with 65 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ namespace low_precision {
class LP_TRANSFORMATIONS_API CleanupTransformation : public LayerTransformation {
public:
CleanupTransformation(const Params& params);
virtual ~CleanupTransformation() = default;

bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
static bool canBeTransformedStatic(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ namespace low_precision {
class LP_TRANSFORMATIONS_API FuseElementwiseToFakeQuantizeTransformation : public CleanupTransformation {
public:
FuseElementwiseToFakeQuantizeTransformation(const Params& params);
virtual ~FuseElementwiseToFakeQuantizeTransformation() = default;

bool canBeTransformed(const TransformationContext& context, std::shared_ptr<Node> layer) const override;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,6 @@ class LP_TRANSFORMATIONS_API LayerTransformation : public ov::pass::MatcherPass
};

LayerTransformation(const Params& params);
virtual ~LayerTransformation() = default;
virtual bool transform(TransformationContext& context, ov::pass::pattern::Matcher &m) = 0;

void setContext(TransformationContext* context) noexcept;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
template <class T>
class LP_TRANSFORMATIONS_API SharedAttribute : public ov::RuntimeAttribute {
public:
virtual ~SharedAttribute() = default;

/**
* @ingroup ov_transformation_common_api
* @brief SharedValueAttribute type for shared value attributes.
Expand Down
4 changes: 1 addition & 3 deletions src/core/include/openvino/core/any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ class OPENVINO_API Any {
template <class U, class T, class... Others>
U convert_impl() const;

virtual ~Base() = default;
virtual ~Base();
};

template <class T, typename = void>
Expand Down Expand Up @@ -611,8 +611,6 @@ class OPENVINO_API Any {
template <typename... Args>
Impl(Args&&... args) : value(std::forward<Args>(args)...) {}

virtual ~Impl(){};

const std::type_info& type_info() const override {
return typeid(T);
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/openvino/core/attribute_adapter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class OPENVINO_API ValueAccessor<void> {
/// \brief type info enables identification of the value accessor, as well as is_type and
/// as_type.
virtual const DiscreteTypeInfo& get_type_info() const = 0;
virtual ~ValueAccessor() = default;
virtual ~ValueAccessor();
virtual void set_as_any(const ov::Any& x) {
OPENVINO_NOT_IMPLEMENTED;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/openvino/core/attribute_visitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class VisitorAdapter;
/// deserialization.
class OPENVINO_API AttributeVisitor {
public:
virtual ~AttributeVisitor() = default;
virtual ~AttributeVisitor();
// Must implement these methods
/// \brief handles all specialized on_adapter methods implemented by the visitor.
///
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/openvino/core/model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class OPENVINO_API Model : public std::enable_shared_from_this<Model> {
/// based on traversing the graph from the results and the sinks.
Model(const ov::OutputVector& results, const ov::SinkVector& sinks, const std::string& name = "");

virtual ~Model() = default;
virtual ~Model();
/// Return the number of outputs for this Model.
size_t get_output_size() const;

Expand Down
2 changes: 1 addition & 1 deletion src/core/include/openvino/core/runtime_attribute.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class OPENVINO_API RuntimeAttribute {
}
using Ptr = std::shared_ptr<RuntimeAttribute>;
using Base = std::tuple<::ov::RuntimeAttribute>;
virtual ~RuntimeAttribute() = default;
virtual ~RuntimeAttribute();
virtual bool is_copyable() const;
virtual bool is_copyable(const std::shared_ptr<Node>& to) const;
virtual Any init(const std::shared_ptr<Node>& node) const;
Expand Down
8 changes: 4 additions & 4 deletions src/core/include/openvino/op/util/multi_subgraph_base.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class OPENVINO_API MultiSubGraphOp : public ov::op::Sink {
OPENVINO_OP("MultiSubGraphOp", "util", ov::op::Sink);
/// \brief Abstract class describes a connection between a MultiSubGraphOp input and
/// the body.
class InputDescription {
class OPENVINO_API InputDescription {
protected:
///
/// \brief Constructs a new instance.
Expand All @@ -34,7 +34,7 @@ class OPENVINO_API MultiSubGraphOp : public ov::op::Sink {
public:
using Ptr = std::shared_ptr<InputDescription>;
using type_info_t = DiscreteTypeInfo;
virtual ~InputDescription() = default;
virtual ~InputDescription();
virtual std::shared_ptr<InputDescription> copy() const = 0;

virtual const type_info_t& get_type_info() const = 0;
Expand All @@ -45,7 +45,7 @@ class OPENVINO_API MultiSubGraphOp : public ov::op::Sink {

/// \brief Abstract class describes how a MultiSubGraphOp output is produced from
/// the body.
class OutputDescription {
class OPENVINO_API OutputDescription {
protected:
///
/// \brief Constructs a new instance.
Expand All @@ -59,7 +59,7 @@ class OPENVINO_API MultiSubGraphOp : public ov::op::Sink {
public:
using Ptr = std::shared_ptr<OutputDescription>;
using type_info_t = DiscreteTypeInfo;
virtual ~OutputDescription() = default;
virtual ~OutputDescription();
virtual std::shared_ptr<OutputDescription> copy() const = 0;
virtual const type_info_t& get_type_info() const = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/core/include/openvino/op/util/variable_extension.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class OPENVINO_API VariableExtension {
virtual std::string get_variable_id() const = 0;

protected:
virtual ~VariableExtension(){};
virtual ~VariableExtension();

protected:
std::shared_ptr<Variable> m_variable;
Expand Down
2 changes: 1 addition & 1 deletion src/core/include/openvino/pass/pass.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class OPENVINO_API PassBase {

public:
PassBase();
virtual ~PassBase() = default;
virtual ~PassBase();
/// Check if this pass has all the pass properties.
bool get_property(const PassPropertyMask& prop_mask) const;

Expand Down
5 changes: 3 additions & 2 deletions src/core/include/openvino/pass/pattern/matcher.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,8 @@ class OPENVINO_API Matcher {
Matcher(std::shared_ptr<Node> pattern_node, const std::string& name);
Matcher(std::shared_ptr<Node> pattern_node, const std::string& name, bool strict_mode);

virtual ~Matcher() = default;
virtual ~Matcher();

/// \brief Matches a pattern to \p graph_node
///
/// \param graph_value is an input graph to be matched against
Expand Down Expand Up @@ -176,7 +177,7 @@ class OPENVINO_API Matcher {

size_t add_node(Output<Node> node);

bool virtual match_value(const ov::Output<Node>& pattern_value, const ov::Output<Node>& graph_value);
virtual bool match_value(const ov::Output<Node>& pattern_value, const ov::Output<Node>& graph_value);

bool is_strict_mode() {
return m_strict_mode;
Expand Down
4 changes: 2 additions & 2 deletions src/core/include/openvino/runtime/allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class OPENVINO_API Allocator {

friend class ov::Tensor;

struct Base : public std::enable_shared_from_this<Base> {
struct OPENVINO_API Base : public std::enable_shared_from_this<Base> {
virtual void* addressof() = 0;
const void* addressof() const {
return const_cast<Base*>(this)->addressof();
Expand All @@ -48,7 +48,7 @@ class OPENVINO_API Allocator {
virtual bool is_equal(const Base& other) const = 0;

protected:
virtual ~Base() = default;
virtual ~Base();
};

template <typename A>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class PhiloxConverter {
public:
PhiloxConverter() = delete;

virtual ~PhiloxConverter(){};
virtual ~PhiloxConverter() = default;

/// \brief Returns the number of generated elements per execution
/// based on the requested data type.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class PhiloxGenerator {
public:
PhiloxGenerator() = delete;

virtual ~PhiloxGenerator(){};
virtual ~PhiloxGenerator() = default;

/// @brief Get a set of 4 random 32-bit unsigned integers based on the seed(s).
/// @return A vector with a random set of 4 32-bit unsigned integers.
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ bool util::equal(std::type_index lhs, std::type_index rhs) {
return result;
}

Any::Base::~Base() = default;

bool Any::Base::is(const std::type_info& other) const {
return util::equal(type_info(), other);
}
Expand Down
4 changes: 4 additions & 0 deletions src/core/src/attribute_visitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@

using namespace std;

ov::ValueAccessor<void>::~ValueAccessor() = default;

ov::AttributeVisitor::~AttributeVisitor() = default;

void ov::AttributeVisitor::start_structure(const string& name) {
m_context.push_back(name);
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ ov::Model::Model(const ov::OutputVector& results, const ov::SinkVector& sinks, c

ov::Model::Model(const OutputVector& results, const string& name) : Model(results, ov::SinkVector{}, name) {}

ov::Model::~Model() = default;

void ov::Model::prerequirements(bool detect_variables, bool detect_parameters) {
OV_ITT_SCOPED_TASK(ov::itt::domains::core, "Model::prerequirements");

Expand Down
4 changes: 4 additions & 0 deletions src/core/src/op/util/multi_subgraph_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ ov::op::util::MultiSubGraphOp::InputDescription::InputDescription(uint64_t input
: m_input_index(input_index),
m_body_parameter_index(body_parameter_index) {}

ov::op::util::MultiSubGraphOp::InputDescription::~InputDescription() = default;

ov::op::util::MultiSubGraphOp::OutputDescription::OutputDescription(uint64_t body_value_index, uint64_t output_index)
: m_body_value_index(body_value_index),
m_output_index(output_index) {}

ov::op::util::MultiSubGraphOp::OutputDescription::~OutputDescription() = default;

ov::op::util::MultiSubGraphOp::SliceInputDescription::SliceInputDescription(uint64_t input_index,
uint64_t body_parameter_index,
int64_t start,
Expand Down
9 changes: 9 additions & 0 deletions src/core/src/op/util/variable_extension.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (C) 2018-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/op/util/variable_extension.hpp"

using namespace ov::op::util;

VariableExtension::~VariableExtension() = default;
2 changes: 2 additions & 0 deletions src/core/src/pass/pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ using namespace std;

ov::pass::PassBase::PassBase() : m_property(), m_name(), m_pass_config(std::make_shared<PassConfig>()) {}

ov::pass::PassBase::~PassBase() = default;

bool ov::pass::PassBase::get_property(const PassPropertyMask& prop) const {
return m_property.is_set(prop);
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/pattern/matcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ Matcher::Matcher(std::shared_ptr<Node> pattern_node, const std::string& name)
Matcher::Matcher(std::shared_ptr<Node> pattern_node, const std::string& name, bool strict_mode)
: Matcher(make_node_output(pattern_node), name, strict_mode) {}

Matcher::~Matcher() = default;

MatcherState::~MatcherState() {
if (m_restore) {
if (!m_matcher->m_matched_list.empty()) {
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/runtime/allocator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ struct DefaultAllocator {
}
};

Allocator::Base::~Base() = default;

Allocator::Allocator() : Allocator{DefaultAllocator{}} {}

Allocator::~Allocator() {
Expand Down
2 changes: 2 additions & 0 deletions src/core/src/runtime_attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

namespace ov {

RuntimeAttribute::~RuntimeAttribute() = default;

std::string RuntimeAttribute::to_string() const {
return {};
}
Expand Down
7 changes: 2 additions & 5 deletions src/frontends/common/include/openvino/frontend/decoder.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ struct Union;
} // namespace type

/// Plays a role of node, block and module decoder
class IDecoder {
class FRONTEND_API IDecoder {
public:
virtual ~IDecoder() = default;
virtual ~IDecoder();
};

class FRONTEND_API DecoderBase : public IDecoder {
Expand Down Expand Up @@ -82,9 +82,6 @@ class FRONTEND_API DecoderBase : public IDecoder {

/// \brief Get node name
virtual const std::string& get_op_name() const = 0;

/// \brief Destructor
virtual ~DecoderBase();
};

} // namespace frontend
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,6 @@ class FRONTEND_API GraphIterator : ::ov::RuntimeAttribute {
/// \brief Return a pointer to a decoder of the current node
virtual std::shared_ptr<DecoderBase> get_decoder() const = 0;

/// \brief Destructor
virtual ~GraphIterator() = default;

/// \brief Checks if the main model graph contains a function of the requested name in the library
/// Returns GraphIterator to this function and nullptr, if it does not exist
virtual std::shared_ptr<GraphIterator> get_body_graph_iterator(const std::string& func_name) const = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class FRONTEND_API InputModel {
InputModel& operator=(const InputModel&) = delete;
InputModel& operator=(InputModel&&) = delete;

virtual ~InputModel() = default;
virtual ~InputModel();

///// Searching for places /////

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class FRONTEND_API NodeContext {
public:
// TODO: Why this ctor is explicit when get_op_type is virtual so m_op_type looks to be a custom implementation
explicit NodeContext(const std::string& op_type) : m_op_type(op_type) {}
virtual ~NodeContext() = default;
virtual ~NodeContext();

/// \brief Returns a number of inputs
virtual size_t get_input_size() const {
Expand Down
2 changes: 1 addition & 1 deletion src/frontends/common/include/openvino/frontend/place.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class FRONTEND_API Place {
public:
typedef std::shared_ptr<Place> Ptr;

virtual ~Place() = 0;
virtual ~Place();

/// \brief All associated names (synonyms) that identify this place in the graph in a
/// framework specific way
Expand Down
2 changes: 1 addition & 1 deletion src/frontends/common/src/decoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

using namespace ov::frontend;

DecoderBase::~DecoderBase() = default;
IDecoder::~IDecoder() = default;
2 changes: 2 additions & 0 deletions src/frontends/common/src/input_model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
using namespace ov;
using namespace ov::frontend;

InputModel::~InputModel() = default;

std::vector<Place::Ptr> InputModel::get_inputs() const {
if (!m_actual) {
return {};
Expand Down
9 changes: 9 additions & 0 deletions src/frontends/common/src/node_context.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Copyright (C) 2018-2025 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "openvino/frontend/node_context.hpp"

using namespace ov::frontend;

NodeContext::~NodeContext() = default;
2 changes: 1 addition & 1 deletion src/frontends/common/src/variable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@

using namespace ov::frontend;

Variable::~Variable(){};
Variable::~Variable() = default;

0 comments on commit 1e9a7e8

Please sign in to comment.