Skip to content

Commit df9b99d

Browse files
jane-intelmlukasze
andauthoredApr 25, 2024
[ov::Symbol] get rid of self pointing for root symbol (openvinotoolkit#24137)
### Details: - *gets rid of self-pointing for root symbol* Co-authored-by: Michal Lukaszewski <michal.lukaszewski@intel.com>
1 parent 604cfcd commit df9b99d

File tree

2 files changed

+5
-14
lines changed

2 files changed

+5
-14
lines changed
 

‎src/core/include/openvino/core/symbol.hpp

+1-5
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,14 @@ std::shared_ptr<Symbol> OPENVINO_API ancestor_of(const std::shared_ptr<Symbol>&
2424
/// \brief Class representing unique symbol for the purpose of symbolic shape inference. Equality of symbols is being
2525
/// tracked by Disjoint-set data structure
2626
/// \ingroup ov_model_cpp_api
27-
class OPENVINO_API Symbol : public std::enable_shared_from_this<Symbol> {
27+
class OPENVINO_API Symbol {
2828
public:
2929
/// \brief Default constructs a unique symbol
3030
Symbol() = default;
3131

3232
private:
33-
/// \brief Returns immediate parent of the Symbol, in case parent is unknown sets this as a parent for itself
34-
std::shared_ptr<Symbol> parent();
35-
3633
friend std::shared_ptr<Symbol> ov::symbol::ancestor_of(const std::shared_ptr<Symbol>& x);
3734
friend void ov::symbol::set_equal(const std::shared_ptr<Symbol>& lhs, const std::shared_ptr<Symbol>& rhs);
38-
friend bool ov::symbol::are_equal(const std::shared_ptr<Symbol>& lhs, const std::shared_ptr<Symbol>& rhs);
3935

4036
std::shared_ptr<Symbol> m_parent = nullptr;
4137
};

‎src/core/src/symbol.cpp

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
std::shared_ptr<ov::Symbol> ov::symbol::ancestor_of(const std::shared_ptr<Symbol>& symbol) {
88
auto x = symbol;
9-
while (x->parent().get() != x.get()) {
10-
x->m_parent = x->parent()->parent();
11-
x = x->parent();
9+
while (x->m_parent) {
10+
if (x->m_parent->m_parent)
11+
x->m_parent = x->m_parent->m_parent;
12+
x = x->m_parent;
1213
}
1314
return x;
1415
}
@@ -27,9 +28,3 @@ void ov::symbol::set_equal(const std::shared_ptr<Symbol>& lhs, const std::shared
2728
return; // already are equal
2829
lhs_root->m_parent = rhs_root;
2930
}
30-
31-
std::shared_ptr<ov::Symbol> ov::Symbol::parent() {
32-
if (!m_parent)
33-
m_parent = shared_from_this();
34-
return m_parent;
35-
}

0 commit comments

Comments
 (0)
Please sign in to comment.