From e2fd335b70fd0bd2dc46f424aa90bf4a4c3297c9 Mon Sep 17 00:00:00 2001 From: Gleb Kazantaev Date: Thu, 14 Oct 2021 13:27:50 +0300 Subject: [PATCH] Fix FrameworkNodeAttr Deserialization (#7943) * Fix FrameworkNodeAttr Deserialization * Fix --- .../include/ngraph_ops/framework_node.hpp | 4 +- .../transformations/framework_node.cpp | 43 +++++++++++++++++++ 2 files changed, 45 insertions(+), 2 deletions(-) create mode 100644 inference-engine/tests/functional/inference_engine/transformations/framework_node.cpp diff --git a/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp b/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp index c19a8500ecc..139e063d500 100644 --- a/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp +++ b/inference-engine/src/transformations/include/ngraph_ops/framework_node.hpp @@ -36,12 +36,12 @@ public: attrs_t::const_iterator end() const { return m_attrs.end(); } - std::string operator[](const std::string & key) { return m_attrs[key]; } + std::string& operator[](const std::string & key) { return m_attrs[key]; } std::string at(const std::string & key) const { return m_attrs.at(key); } 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: diff --git a/inference-engine/tests/functional/inference_engine/transformations/framework_node.cpp b/inference-engine/tests/functional/inference_engine/transformations/framework_node.cpp new file mode 100644 index 00000000000..4a4e42c5b34 --- /dev/null +++ b/inference-engine/tests/functional/inference_engine/transformations/framework_node.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "ngraph_ops/framework_node.hpp" + +#include + +#include "gtest/gtest.h" + +TEST(framework_node, attrs) { + ngraph::op::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"); + + ngraph::op::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); +}