// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // #include #include #include #include #include #include #include #include #include #include #include #include #include #include "common_test_utils/ngraph_test_utils.hpp" using namespace testing; using namespace MKLDNNPlugin; TEST(TransformationTests, ConvertMatMulToFCTest1) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{ 3, 2, 2 }); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 1, 2, 2 }, { 1 }); auto matmul = std::make_shared(input1, input2, true, false); f = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{ 3, 2, 2 }); auto transpose_constant = ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{ 3 }, { 0, 2, 1 }); auto transpose = std::make_shared(input1, transpose_constant); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 2, 2 }, { 1 }); auto matmul = std::make_shared(transpose, input2, ngraph::Rank(3)); f_ref = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); } auto res = compare_functions(f, f_ref); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest2) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 1, 2}); auto input2 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 1}); auto matmul = std::make_shared(input1, input2, false, false); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1, input2}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 1, 2}); auto input2 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 1}); auto matmul = std::make_shared(input1, input2, false, false); f_ref = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1, input2}); } auto res = compare_functions(f, f_ref); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest3) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 2}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 2}, {1}); auto matmul = std::make_shared(input1, input2, ngraph::Rank(3)); f_ref = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest4) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, -1, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 2}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, -1, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 2}, {1}); auto matmul = std::make_shared(input1, input2, ngraph::Rank(3)); f_ref = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest5) { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{ -1, -1, 2 }); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 3, 2, 2 }, { 1 }); auto matmul = std::make_shared(input1, input2, false, true); auto f = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); ASSERT_NO_THROW(m.run_passes(f)); } TEST(TransformationTests, ConvertMatMulToFCTest6) { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{ -1, -1, 2 }); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 3, 1, 2 }, { 1 }); auto matmul = std::make_shared(input1, input2, false, true); auto f = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); ASSERT_NO_THROW(m.run_passes(f)); ASSERT_NO_THROW(check_rt_info(f)); } TEST(TransformationTests, ConvertMatMulToFCTest7) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{3, 2}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{3, 2}, {1}); auto reshape_begin = std::make_shared( input1, ngraph::opset1::Constant::create(ngraph::element::i64, ngraph::Shape{2}, std::vector{-1, 2}), false); auto fc = std::make_shared(reshape_begin, input2, ngraph::Rank(2)); auto reshape_end = ngraph::op::util::reshapeTo(fc, ngraph::Shape{3, 2, 3}); f_ref = std::make_shared(ngraph::NodeVector{reshape_end}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest8) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, -1, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{3, 2}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, -1, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{3, 2}, {1}); auto reshape_begin = std::make_shared( input1, ngraph::opset1::Constant::create(ngraph::element::i64, {2}, {-1, 2}), false); auto fc = std::make_shared(reshape_begin, input2, ngraph::Rank(2)); auto a_shape = std::make_shared(input1); auto I = ngraph::op::util::node_to_get_shape_value_of_indices_from_shape_node(a_shape, {0, 1}); auto O = ngraph::opset1::Constant::create(ngraph::element::i64, { 1 }, { 3 }); auto output_shape = std::make_shared(ngraph::OutputVector{I, O}, 0); auto reshape_end = std::make_shared(fc, output_shape, false); f_ref = std::make_shared(ngraph::NodeVector{reshape_end}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest9) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 2}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; auto pass_config = m.get_pass_config(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{3, 2, 2}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 2}, {1}); auto matmul = std::make_shared(input1, input2, ngraph::Rank(3)); f_ref = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest10) { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape::dynamic()); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 2, 2 }, { 1 }); auto matmul = std::make_shared(input1, input2, false, true); auto f = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); ASSERT_NO_THROW(m.run_passes(f)); } TEST(TransformationTests, FullyConnectedBiasFusionTest1) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 128, 3072}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 3072}, {1}); auto fc = std::make_shared(input1, weights, ngraph::Rank(3)); auto const_bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786}, {1}); auto add = std::make_shared(fc, const_bias); f = std::make_shared(ngraph::NodeVector{add}, ngraph::ParameterVector{input1}); ngraph::pass::Manager manager; manager.register_pass(); manager.register_pass(); manager.register_pass([](std::shared_ptr f) { check_rt_info(f); }); ASSERT_NO_THROW(manager.run_passes(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 128, 3072}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 3072}, {1}); auto bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786}, {1}); auto fc = std::make_shared(input1, weights, bias, ngraph::Rank(3)); f_ref = std::make_shared(ngraph::NodeVector{fc}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, FullyConnectedBiasFusionTest2) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, -1, 3072}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 3072}, {1}); auto fc = std::make_shared(input1, weights, ngraph::Rank(3)); auto const_bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786}, {1}); auto add = std::make_shared(fc, const_bias); f = std::make_shared(ngraph::NodeVector{add}, ngraph::ParameterVector{input1}); ngraph::pass::Manager manager; manager.register_pass(); manager.register_pass(); manager.register_pass([](std::shared_ptr f) { check_rt_info(f); }); ASSERT_NO_THROW(manager.run_passes(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, -1, 3072}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 3072}, {1}); auto bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786}, {1}); auto fc = std::make_shared(input1, weights, bias, ngraph::Rank(3)); f_ref = std::make_shared(ngraph::NodeVector{fc}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, FullyConnectedBiasFusionTest3) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 128}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 128}, {1}); auto fc = std::make_shared(input1, weights, ngraph::Rank(2)); auto const_bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{1, 786}, {1}); auto add = std::make_shared(fc, const_bias); f = std::make_shared(ngraph::NodeVector{add}, ngraph::ParameterVector{input1}); ngraph::pass::Manager manager; manager.register_pass(); manager.register_pass(); manager.register_pass([](std::shared_ptr f) { check_rt_info(f); }); ASSERT_NO_THROW(manager.run_passes(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{1, 128}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 128}, {1}); auto bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786}, {1}); auto fc = std::make_shared(input1, weights, bias, ngraph::Rank(2)); f_ref = std::make_shared(ngraph::NodeVector{fc}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, FullyConnectedBiasFusionTest4) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, 128}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 128}, {1}); auto fc = std::make_shared(input1, weights, ngraph::Rank(2)); auto const_bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{1, 786}, {1}); auto add = std::make_shared(fc, const_bias); f = std::make_shared(ngraph::NodeVector{add}, ngraph::ParameterVector{input1}); ngraph::pass::Manager manager; manager.register_pass(); manager.register_pass(); manager.register_pass([](std::shared_ptr f) { check_rt_info(f); }); ASSERT_NO_THROW(manager.run_passes(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, 128}); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786, 128}, {1}); auto bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{786}, {1}); auto fc = std::make_shared(input1, weights, bias, ngraph::Rank(2)); f_ref = std::make_shared(ngraph::NodeVector{fc}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, FullyConnectedBiasFusionTest5) { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape::dynamic()); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 786, 128 }, { 1 }); auto fc = std::make_shared(input1, weights, ngraph::Rank(2)); auto const_bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 1, 786 }, { 1 }); auto add = std::make_shared(fc, const_bias); auto f = std::make_shared(ngraph::NodeVector{ add }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager manager; manager.register_pass(); ASSERT_NO_THROW(manager.run_passes(f)); } TEST(TransformationTests, FullyConnectedBiasFusionTest6) { auto input1 = std::make_shared(ngraph::element::u8, ngraph::PartialShape{ -1, -1 }); auto weights = ngraph::opset1::Constant::create(ngraph::element::i8, ngraph::Shape{ 786, 128 }, { 1 }); auto fc = std::make_shared(input1, weights, ngraph::Rank(2), ngraph::element::f32); auto const_bias = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 1, 786 }, { 1 }); auto add = std::make_shared(fc, const_bias); auto f = std::make_shared(ngraph::NodeVector{ add }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager manager; manager.register_pass(); ASSERT_NO_THROW(manager.run_passes(f)); } TEST(TransformationTests, ConvertMatMulToFCTest_second_input_rank_adj_1) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{5, 2, 3}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{1, 1, 2, 3}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{5, 2, 3}); auto reshape_1 = std::make_shared(input1, ngraph::opset1::Constant::create(ngraph::element::i64, {2}, {-1, 3}), false); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 3}, {1}); auto matmul = std::make_shared(reshape_1, input2, ngraph::Rank(2)); auto reshape_out = std::make_shared(matmul, ngraph::opset1::Constant::create(ngraph::element::i64, {4}, {1, 5, 2, 2}), false); f_ref = std::make_shared(ngraph::NodeVector{reshape_out}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest_second_input_rank_adj_2) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{ 2, 3 }); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 2, 3 }, { 1 }); auto matmul = std::make_shared(input1, weights, false, true); f = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{ 2, 3 }); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 2, 3 }, { 1 }); auto matmul = std::make_shared(input1, weights, ngraph::Rank(2)); f_ref = std::make_shared(ngraph::NodeVector{ matmul }, ngraph::ParameterVector{ input1 }); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest_second_input_rank_adj_3) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{ 5, 2, 3 }); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 1, 1, 2, 3 }, { 1 }); auto matmul = std::make_shared(input1, weights, false, true); auto biases = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 1, 1, 1, 2 }, { 1 }); auto add = std::make_shared(matmul, biases); f = std::make_shared(ngraph::NodeVector{ add }, ngraph::ParameterVector{ input1 }); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::Shape{ 5, 2, 3 }); auto reshape_before_const = ngraph::opset1::Constant::create(ngraph::element::i64, { 2 }, { -1, 3 }); auto reshape_1 = std::make_shared(input1, reshape_before_const, false); auto weights = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 2, 3 }, { 1 }); auto biases = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{ 2 }, { 1 }); auto matmul = std::make_shared(reshape_1, weights, biases, ngraph::Rank(2)); auto reshape_after_const = ngraph::opset1::Constant::create(ngraph::element::i64, { 4 }, { 1, 5, 2, 2 }); auto reshape_out = std::make_shared(matmul, reshape_after_const, false); f_ref = std::make_shared(ngraph::NodeVector{ reshape_out }, ngraph::ParameterVector{ input1 }); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; } TEST(TransformationTests, ConvertMatMulToFCTest_second_input_rank_adj_dynamic) { std::shared_ptr f(nullptr), f_ref(nullptr); { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, 2, 3}); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{1, 1, 2, 3}, {1}); auto matmul = std::make_shared(input1, input2, false, true); f = std::make_shared(ngraph::NodeVector{matmul}, ngraph::ParameterVector{input1}); ngraph::pass::Manager m; m.register_pass(); m.register_pass(); m.register_pass(); m.run_passes(f); ASSERT_NO_THROW(check_rt_info(f)); } { auto input1 = std::make_shared(ngraph::element::f32, ngraph::PartialShape{-1, 2, 3}); auto reshape_1 = std::make_shared(input1, ngraph::opset1::Constant::create(ngraph::element::i64, {2}, {-1, 3}), false); auto input2 = ngraph::opset1::Constant::create(ngraph::element::f32, ngraph::Shape{2, 3}, {1}); auto matmul = std::make_shared(reshape_1, input2, ngraph::Rank(2)); auto shape_of = std::make_shared(input1); auto gather = std::make_shared( shape_of, ngraph::opset1::Constant::create(ngraph::element::i64, {2}, {0, 1}), ngraph::opset1::Constant::create(ngraph::element::i64, {}, {0})); auto concat = std::make_shared(ngraph::OutputVector{ ngraph::opset1::Constant::create(ngraph::element::i64, {1}, {1}), gather, ngraph::opset1::Constant::create(ngraph::element::i64, {1}, {2}), }, 0); auto reshape_out = std::make_shared(matmul, concat, false); f_ref = std::make_shared(ngraph::NodeVector{reshape_out}, ngraph::ParameterVector{input1}); } auto res = compare_functions(f, f_ref, true); ASSERT_TRUE(res.first) << res.second; }