Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FrameworkNodeAttr Deserialization #7854

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ngraph/core/include/openvino/op/util/framework_node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class OPENVINO_API FrameworkNodeAttrs {
return m_attrs.end();
}

std::string operator[](const std::string& key) {
std::string& operator[](const std::string& key) {
return m_attrs[key];
}

Expand All @@ -59,7 +59,7 @@ class OPENVINO_API FrameworkNodeAttrs {
}

bool operator==(const FrameworkNodeAttrs& other) const {
return m_type_name == other.m_type_name && m_opset_name == other.m_opset_name && m_attrs == m_attrs;
return m_type_name == other.m_type_name && m_opset_name == other.m_opset_name && m_attrs == other.m_attrs;
}

private:
Expand Down
1 change: 1 addition & 0 deletions ngraph/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ set(SRC
eval.cpp
file_util.cpp
float16.cpp
framework_node.cpp
function.cpp
graph_rewrite.cpp
includes.cpp
Expand Down
43 changes: 43 additions & 0 deletions ngraph/test/framework_node.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright (C) 2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//

#include "ngraph/op/util/framework_node.hpp"

#include <vector>

#include "gtest/gtest.h"

TEST(framework_node, attrs) {
ov::op::util::FrameworkNodeAttrs attrs;

attrs.set_opset_name("opset_name");
ASSERT_EQ(attrs.get_opset_name(), "opset_name");

attrs.set_type_name("type_name");
ASSERT_EQ(attrs.get_type_name(), "type_name");

attrs["attr1"] = "value1";
ASSERT_EQ(attrs.at("attr1"), "value1");
ASSERT_EQ(attrs.begin()->first, "attr1");
ASSERT_EQ(attrs.begin()->first, "attr1");
ASSERT_EQ(attrs.begin()->second, "value1");

ov::op::util::FrameworkNodeAttrs a1, a2;
a1.set_type_name("type_name");
a2.set_type_name("type_name_");
ASSERT_FALSE(a1 == a2);
a2.set_type_name("type_name");
ASSERT_TRUE(a1 == a2);
a1.set_opset_name("opset_name");
a2.set_opset_name("opset_name_");
ASSERT_FALSE(a1 == a2);
a2.set_opset_name("opset_name");
ASSERT_TRUE(a1 == a2);
a1["attr"] = "value";
ASSERT_FALSE(a1 == a2);
a2["attr"] = "value_";
ASSERT_FALSE(a1 == a2);
a2["attr"] = "value";
ASSERT_TRUE(a1 == a2);
}