From 1d226d4edc2f20738683a9cfdf3ac16ba72eceff Mon Sep 17 00:00:00 2001 From: Alexandra Sidorova Date: Tue, 11 Jun 2024 19:45:40 +0300 Subject: [PATCH] [Snippets] Added dynamic Transpose support (#24733) ### Details: - *Added dynamic Transpose support (updated related operations and passes)* - *Added dynamic tests with Transpose* ### Tickets: - *142098* ### Prerequisites: - https://github.com/openvinotoolkit/openvino/pull/24525 - https://github.com/openvinotoolkit/openvino/pull/24646 --- src/common/snippets/src/op/load.cpp | 3 +- .../snippets/src/pass/collapse_subgraph.cpp | 3 +- .../pass/explicit_transpose_matmul_inputs.cpp | 8 ++-- .../src/pass/fuse_transpose_brgemm.cpp | 4 +- .../src/pass/transpose_decomposition.cpp | 14 ++++--- .../snippets/transpose.cpp | 39 +++++++++++++++++-- .../snippets/transpose_softmax.cpp | 24 ++++++++++-- .../shared/include/snippets/transpose.hpp | 21 +++++----- .../include/snippets/transpose_softmax.hpp | 12 +++--- .../plugin/shared/src/snippets/transpose.cpp | 28 ++++++------- .../shared/src/snippets/transpose_softmax.cpp | 19 +++++---- .../include/subgraph_softmax.hpp | 4 +- .../src/subgraph_softmax.cpp | 6 +-- 13 files changed, 119 insertions(+), 66 deletions(-) diff --git a/src/common/snippets/src/op/load.cpp b/src/common/snippets/src/op/load.cpp index d48641c17cc..08352e025c9 100644 --- a/src/common/snippets/src/op/load.cpp +++ b/src/common/snippets/src/op/load.cpp @@ -44,11 +44,10 @@ std::shared_ptr Load::clone_with_new_inputs(const OutputVector& new_args) LoadReshape::LoadReshape(const Output& x, const size_t count, const size_t offset, std::vector order) : Load(x, count, offset), m_order(std::move(order)) { const auto& in_shape = x.get_partial_shape(); - OPENVINO_ASSERT(in_shape.is_static(), "LoadReshape supports only static input shapes"); const auto in_shape_size = in_shape.size(); OPENVINO_ASSERT(m_order.size() == in_shape_size, "LoadReshape got new_order of invalid size"); OPENVINO_ASSERT(*std::max_element(m_order.begin(), m_order.end()) == in_shape_size - 1 && - *std::min_element(m_order.begin(), m_order.end()) == 0, "LoadReshape detected invalid values in new_order"); + *std::min_element(m_order.begin(), m_order.end()) == 0, "LoadReshape detected invalid values in new_order"); const std::set unique_dims(order.begin(), order.end()); OPENVINO_ASSERT(unique_dims.size() == order.size(), "LoadReshape order must not contain repeated elements"); constructor_validate_and_infer_types(); diff --git a/src/common/snippets/src/pass/collapse_subgraph.cpp b/src/common/snippets/src/pass/collapse_subgraph.cpp index 0295e1eb6ef..b63b9612f81 100644 --- a/src/common/snippets/src/pass/collapse_subgraph.cpp +++ b/src/common/snippets/src/pass/collapse_subgraph.cpp @@ -59,8 +59,7 @@ auto is_supported_op(const std::shared_ptr &n) -> bool { }; auto is_supported_transpose = [](const std::shared_ptr& n) -> bool { const auto& transpose = as_type_ptr(n); - const auto& out_shape = n->get_output_partial_shape(0); - if (transpose && out_shape.is_static()) { + if (transpose) { const auto parent = transpose->get_input_node_shared_ptr(0); const auto child = transpose->get_output_target_inputs(0).begin()->get_node()->shared_from_this(); auto is_brgemm_case = ov::is_type(parent) || ov::is_type(child); diff --git a/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp b/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp index f384abcb08c..bf8de657061 100644 --- a/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp +++ b/src/common/snippets/src/pass/explicit_transpose_matmul_inputs.cpp @@ -57,8 +57,8 @@ void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input< OPENVINO_ASSERT(consumers.size() == 1, "ExplicitTransposeMatMulInputs expects Parameter with one consumer in cases when there isn't existing Transpose on input"); // Extract Transpose from MatMul - OPENVINO_ASSERT(input.get_partial_shape().is_static(), "ExplicitTransposeMatMulInputs supports only static shapes"); - const auto rank = input.get_shape().size(); + OPENVINO_ASSERT(input.get_partial_shape().rank().is_static(), "ExplicitTransposeMatMulInputs supports only static ranks of shapes"); + const auto rank = input.get_partial_shape().size(); std::vector transpose_order(rank, 0); std::iota(transpose_order.begin(), transpose_order.end(), 0); std::swap(transpose_order[rank - 1], transpose_order[rank - 2]); @@ -72,9 +72,7 @@ void ov::snippets::pass::ExplicitTransposeMatMulInputs::extract(const ov::Input< ov::snippets::pass::ExplicitTransposeMatMulInputs::ExplicitTransposeMatMulInputs() { MATCHER_SCOPE(ExplicitTransposeMatMulInputs); - auto m_matmul0 = std::make_shared( - ov::pass::pattern::any_input(ov::pass::pattern::has_static_shape()), - ov::pass::pattern::any_input(ov::pass::pattern::has_static_shape())); + auto m_matmul0 = std::make_shared(ov::pass::pattern::any_input(), ov::pass::pattern::any_input()); register_matcher(std::make_shared(m_matmul0, matcher_name), [=](ov::pass::pattern::Matcher &m) { diff --git a/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp b/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp index 0edefb513f7..223f6d91940 100644 --- a/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp +++ b/src/common/snippets/src/pass/fuse_transpose_brgemm.cpp @@ -61,7 +61,7 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() { const auto& transpose_out = m.get_match_value(); const auto& const_order = ov::as_type_ptr(transpose_out.get_node_shared_ptr()->get_input_node_shared_ptr(1)); const auto& original_port = ov::snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(brgemm_out); - original_port->set_shape(transpose_out.get_shape()); + original_port->set_shape(utils::pshape_to_vdims(transpose_out.get_partial_shape())); original_port->set_layout(const_order->cast_vector()); for (const auto& in : transpose_out.get_target_inputs()) in.replace_source_output(brgemm->output(0)); @@ -75,7 +75,7 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() { const auto& const_order = ov::as_type_ptr(transpose->get_input_node_shared_ptr(1)); brgemm->set_argument(i, transpose->input_value(0)); const auto& original_port = ov::snippets::lowered::PortDescriptorUtils::get_port_descriptor_ptr(in); - original_port->set_shape(transpose->get_input_shape(0)); + original_port->set_shape(utils::pshape_to_vdims(transpose->get_input_partial_shape(0))); original_port->set_layout(const_order->cast_vector()); } } diff --git a/src/common/snippets/src/pass/transpose_decomposition.cpp b/src/common/snippets/src/pass/transpose_decomposition.cpp index e921fa03f00..9c280e4806e 100644 --- a/src/common/snippets/src/pass/transpose_decomposition.cpp +++ b/src/common/snippets/src/pass/transpose_decomposition.cpp @@ -49,7 +49,7 @@ TransposeDecomposition::TransposeDecomposition() { const auto transpose = ov::as_type_ptr(pattern_to_output.at(match_transpose).get_node_shared_ptr()); const auto order = ov::as_type_ptr(pattern_to_output.at(match_order).get_node_shared_ptr()); - if (transformation_callback(transpose) || transpose->is_dynamic()) + if (transformation_callback(transpose)) return false; auto order_value = order->cast_vector(); @@ -65,10 +65,14 @@ TransposeDecomposition::TransposeDecomposition() { auto load = std::make_shared(data_input, subtensor[0], 0, layout); auto store = std::make_shared(load, subtensor[0]); - PortDescriptorUtils::set_port_descriptor_ptr(load->input(0), std::make_shared(load->get_input_shape(0), subtensor, layout)); - PortDescriptorUtils::set_port_descriptor_ptr(load->output(0), std::make_shared(load->get_output_shape(0), subtensor)); - PortDescriptorUtils::set_port_descriptor_ptr(store->input(0), std::make_shared(store->get_input_shape(0), subtensor)); - PortDescriptorUtils::set_port_descriptor_ptr(store->output(0), std::make_shared(store->get_output_shape(0), subtensor)); + PortDescriptorUtils::set_port_descriptor_ptr(load->input(0), + std::make_shared(utils::pshape_to_vdims(load->get_input_partial_shape(0)), subtensor, layout)); + PortDescriptorUtils::set_port_descriptor_ptr(load->output(0), + std::make_shared(utils::pshape_to_vdims(load->get_output_partial_shape(0)), subtensor)); + PortDescriptorUtils::set_port_descriptor_ptr(store->input(0), + std::make_shared(utils::pshape_to_vdims(store->get_input_partial_shape(0)), subtensor)); + PortDescriptorUtils::set_port_descriptor_ptr(store->output(0), + std::make_shared(utils::pshape_to_vdims(store->get_output_partial_shape(0)), subtensor)); for (auto& input : transpose->output(0).get_target_inputs()) { input.replace_source_output(store->output(0)); diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose.cpp index 4212102e569..905c27c4644 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose.cpp @@ -11,8 +11,26 @@ namespace snippets { namespace { -std::vector input_shapes_4D{{2, 3, 5, 13}, {2, 3, 2, 4}, {1, 7, 1, 4}}; -std::vector input_shapes_3D{{3, 5, 13}, {3, 2, 4}, {7, 1, 4}}; + +const std::vector input_shapes_3D = { + {{}, {{3, 5, 13}}}, + {{}, {{3, 2, 4}}}, + {{}, {{7, 1, 4}}}, + {{-1, -1, -1}, {{7, 1, 4}, {5, 7, 18}, {5, 7, 18}, {7, 1, 4}}}, + {{10, -1, -1}, {{10, 1, 4}, {10, 17, 18}, {10, 7, 18}, {10, 1, 4}}}, + {{10, -1, 15}, {{10, 1, 15}, {10, 1, 15}, {10, 7, 15}, {10, 15, 15}}}, +}; + +const std::vector input_shapes_4D = { + {{}, {{2, 3, 5, 13}}}, + {{}, {{2, 3, 2, 4}}}, + {{}, {{1, 7, 1, 4}}}, + {{-1, -1, -1, -1}, {{1, 7, 1, 4}, {2, 3, 2, 4}, {8, 7, 1, 4}, {2, 3, 2, 4}, {1, 7, 1, 4}}}, + {{-1, 9, -1, -1}, {{1, 9, 1, 4}, {2, 9, 2, 4}, {8, 9, 1, 4}, {1, 9, 1, 4}, {1, 9, 1, 4}, {2, 9, 2, 4}}}, + {{-1, -1, -1, 5}, {{2, 8, 2, 5}, {2, 8, 2, 5}, {8, 2, 5, 5}, {1, 2, 5, 5}, {8, 3, 5, 5}}}, + {{-1, 9, -1, 5}, {{1, 9, 1, 5}, {2, 9, 2, 5}, {8, 9, 5, 5}, {1, 9, 5, 5}, {8, 9, 5, 5}}}, + {{2, -1, -1, -1}, {{2, 7, 1, 4}, {2, 3, 2, 4}, {2, 7, 1, 4}, {2, 3, 2, 4}, {2, 7, 1, 4}}}, +}; std::vector> orders_4D{{0, 2, 3, 1}}; std::vector> orders_3D{{1, 2, 0}}; @@ -34,10 +52,23 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_Transpose_4D, Transpose, ::testing::Values(ov::test::utils::DEVICE_CPU)), Transpose::getTestCaseName); +const std::vector> inputShapesPair = { + {{{}, {{2, 31, 3, 5}}}, {{}, {{2, 3, 5, 31}}}}, + {{{-1, -1, -1, -1}, {{2, 31, 3, 5}, {2, 33, 4, 5}, {2, 33, 4, 5}}}, + {{-1, -1, -1, -1}, {{2, 3, 5, 31}, {2, 4, 5, 33}, {2, 4, 5, 33}}}}, + {{{-1, -1, -1, -1}, {{2, 31, 3, 5}, {2, 33, 4, 5}, {2, 33, 4, 5}}}, + {{-1, -1, 1, 1}, {{2, 3, 1, 1}, {2, 4, 1, 1}, {2, 4, 1, 1}}}}, + {{{-1, 33, -1, -1}, {{2, 33, 3, 5}, {2, 33, 4, 5}, {2, 33, 2, 5}}}, + {{-1, -1, 1, 1}, {{2, 3, 1, 1}, {2, 4, 1, 1}, {2, 2, 1, 1}}}}, + {{{-1, -1, -1, -1}, {{2, 16, 3, 5}, {2, 8, 4, 5}, {2, 4, 2, 5}}}, + {{-1, -1, -1, 1}, {{2, 3, 1, 1}, {2, 4, 1, 1}, {2, 2, 1, 1}}}}, + {{{-1, 18, -1, -1}, {{2, 18, 3, 5}, {2, 18, 4, 5}, {2, 18, 2, 6}}}, + {{-1, -1, -1, 18}, {{2, 3, 5, 18}, {2, 4, 5, 18}, {2, 2, 6, 18}}}}, +}; + INSTANTIATE_TEST_SUITE_P(smoke_Snippets_TransposeMul, TransposeMul, ::testing::Combine( - ::testing::Values(ov::PartialShape {2, 31, 3, 5}), - ::testing::ValuesIn(std::vector{{2, 3, 5, 31}}), + ::testing::ValuesIn(inputShapesPair), ::testing::Values(std::vector {0, 2, 3, 1}), ::testing::Values(1), // Transpose ::testing::Values(1), // Tokenized Transpose diff --git a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose_softmax.cpp b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose_softmax.cpp index fa03a5e4e6c..3cdb7c193fe 100644 --- a/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose_softmax.cpp +++ b/src/plugins/intel_cpu/tests/functional/shared_tests_instances/snippets/transpose_softmax.cpp @@ -12,13 +12,29 @@ namespace snippets { namespace { -const std::vector inputShape = { - ov::Shape{1, 128, 3, 16}, +const std::vector> inputShape = { + {{{}, {{1, 128, 3, 16}}}}, + {{{-1, -1, -1, -1}, {{1, 128, 3, 16}, {1, 64, 3, 8}, {1, 128, 3, 16}}}}, + {{{-1, 100, -1, -1}, {{1, 100, 3, 16}, {1, 100, 3, 8}, {1, 100, 2, 16}, {1, 100, 3, 8}}}}, + {{{-1, -1, -1, 16}, {{1, 128, 3, 16}, {1, 32, 3, 16}, {1, 32, 3, 16}, {1, 100, 2, 16}}}}, +}; + +const std::vector> inputShapeWithEltwise = { + {{{}, {{1, 128, 3, 16}}}, + {{}, {{1, 3, 16, 128}}}}, + {{{-1, -1, -1, -1}, {{1, 128, 3, 16}, {1, 64, 3, 8}, {1, 128, 3, 16}}}, + {{-1, -1, -1, -1}, {{1, 3, 16, 128}, {1, 3, 8, 64}, {1, 3, 16, 128}}}}, + {{{-1, 100, -1, -1}, {{1, 100, 3, 16}, {1, 100, 3, 8}, {1, 100, 2, 16}, {1, 100, 3, 8}}}, + {{-1, -1, -1, 100}, {{1, 1, 1, 100}, {1, 3, 8, 100}, {1, 2, 16, 100}, {1, 3, 8, 100}}}}, + {{{-1, 100, -1, 3}, {{1, 100, 3, 3}, {1, 100, 3, 3}, {1, 100, 2, 3}, {1, 100, 3, 3}}}, + {{-1, -1, -1, 100}, {{1, 1, 1, 100}, {1, 3, 3, 100}, {1, 2, 3, 100}, {1, 1, 1, 100}}}}, + {{{-1, -1, -1, 16}, {{1, 128, 3, 16}, {1, 32, 3, 16}, {1, 32, 3, 16}, {1, 100, 2, 16}}}, + {{-1, -1, 16, -1}, {{1, 3, 16, 128}, {1, 1, 16, 32}, {1, 3, 16, 32}, {1, 2, 16, 100}}}}, }; INSTANTIATE_TEST_SUITE_P(smoke_Snippets_TransposeSoftmax, TransposeSoftmax, ::testing::Combine( - ::testing::Values(inputShape), + ::testing::ValuesIn(inputShape), ::testing::Values(std::vector{0, 2, 3, 1}), ::testing::Values(-1), ::testing::Values(1), @@ -28,7 +44,7 @@ INSTANTIATE_TEST_SUITE_P(smoke_Snippets_TransposeSoftmax, TransposeSoftmax, INSTANTIATE_TEST_SUITE_P(smoke_Snippets_TransposeSoftmaxEltwise, TransposeSoftmaxEltwise, ::testing::Combine( - ::testing::Values(inputShape), + ::testing::ValuesIn(inputShapeWithEltwise), ::testing::Values(std::vector{0, 2, 3, 1}), ::testing::Values(-1), ::testing::Values(1), diff --git a/src/tests/functional/plugin/shared/include/snippets/transpose.hpp b/src/tests/functional/plugin/shared/include/snippets/transpose.hpp index 37a374d4229..beec2c3750c 100644 --- a/src/tests/functional/plugin/shared/include/snippets/transpose.hpp +++ b/src/tests/functional/plugin/shared/include/snippets/transpose.hpp @@ -11,20 +11,19 @@ namespace test { namespace snippets { typedef std::tuple< - ov::PartialShape, // Input 0 Shape - std::vector, // Transpose order - size_t, // Expected num nodes - size_t, // Expected num subgraphs - std::string // Target Device + InputShape, // Input 0 Shape + std::vector, // Transpose order + size_t, // Expected num nodes + size_t, // Expected num subgraphs + std::string // Target Device > TransposeParams; typedef std::tuple< - ov::PartialShape, // Input 0 Shape - ov::PartialShape, // Input 1 Shape - std::vector, // Transpose order - size_t, // Expected num nodes - size_t, // Expected num subgraphs - std::string // Target Device + std::pair, // Input Shapes + std::vector, // Transpose order + size_t, // Expected num nodes + size_t, // Expected num subgraphs + std::string // Target Device > TransposeMulParams; class Transpose : public testing::WithParamInterface, diff --git a/src/tests/functional/plugin/shared/include/snippets/transpose_softmax.hpp b/src/tests/functional/plugin/shared/include/snippets/transpose_softmax.hpp index 952b7528a00..368b5826b34 100644 --- a/src/tests/functional/plugin/shared/include/snippets/transpose_softmax.hpp +++ b/src/tests/functional/plugin/shared/include/snippets/transpose_softmax.hpp @@ -11,12 +11,12 @@ namespace test { namespace snippets { typedef std::tuple< - std::vector, // Input shapes - std::vector, // Transpose Order - int64_t, // Softmax Axis - size_t, // Expected num nodes - size_t, // Expected num subgraphs - std::string // Target Device + std::vector, // Input shapes + std::vector, // Transpose Order + int64_t, // Softmax Axis + size_t, // Expected num nodes + size_t, // Expected num subgraphs + std::string // Target Device > TransposeSoftmaxParams; diff --git a/src/tests/functional/plugin/shared/src/snippets/transpose.cpp b/src/tests/functional/plugin/shared/src/snippets/transpose.cpp index f5c839b6499..5548deec919 100644 --- a/src/tests/functional/plugin/shared/src/snippets/transpose.cpp +++ b/src/tests/functional/plugin/shared/src/snippets/transpose.cpp @@ -12,14 +12,14 @@ namespace test { namespace snippets { std::string Transpose::getTestCaseName(testing::TestParamInfo obj) { - ov::PartialShape inputShape; + InputShape inputShapes; std::vector order; std::string targetDevice; size_t num_nodes, num_subgraphs; - std::tie(inputShape, order, num_nodes, num_subgraphs, targetDevice) = obj.param; + std::tie(inputShapes, order, num_nodes, num_subgraphs, targetDevice) = obj.param; std::ostringstream result; - result << "IS=" << ov::test::utils::partialShape2str({inputShape}) << "_"; + result << "IS=" << inputShapes << "_"; result << "Order=" << ov::test::utils::vec2str(order) << "_"; result << "#N=" << num_nodes << "_"; result << "#S=" << num_subgraphs << "_"; @@ -28,12 +28,12 @@ std::string Transpose::getTestCaseName(testing::TestParamInfo order; std::tie(inputShape, order, ref_num_nodes, ref_num_subgraphs, targetDevice) = this->GetParam(); - init_input_shapes({{{inputShape}, {inputShape.get_shape(), }}}); + init_input_shapes({inputShape}); - auto f = ov::test::snippets::TransposeFunction({inputShape}, order); + auto f = ov::test::snippets::TransposeFunction(inputDynamicShapes, order); function = f.getOriginal(); if (!configuration.count("SNIPPETS_MODE")) { configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"}); @@ -41,15 +41,15 @@ void Transpose::SetUp() { } std::string TransposeMul::getTestCaseName(testing::TestParamInfo obj) { - std::vector inputShapes(2); + std::pair inputShapes; std::vector order; std::string targetDevice; size_t num_nodes, num_subgraphs; - std::tie(inputShapes[0], inputShapes[1], order, num_nodes, num_subgraphs, targetDevice) = obj.param; + std::tie(inputShapes, order, num_nodes, num_subgraphs, targetDevice) = obj.param; std::ostringstream result; - for (int i = 0; i < inputShapes.size(); i++) - result << "IS[" << i << "]=" << ov::test::utils::partialShape2str({inputShapes[i]}) << "_"; + result << "IS[0]=" << inputShapes.first << "_"; + result << "IS[1]=" << inputShapes.second << "_"; result << "Order=" << ov::test::utils::vec2str(order) << "_"; result << "#N=" << num_nodes << "_"; result << "#S=" << num_subgraphs << "_"; @@ -58,11 +58,11 @@ std::string TransposeMul::getTestCaseName(testing::TestParamInfo inputShapes(2); + std::pair inputShapes; std::vector order; - std::tie(inputShapes[0], inputShapes[1], order, ref_num_nodes, ref_num_subgraphs, targetDevice) = this->GetParam(); - init_input_shapes(static_partial_shapes_to_test_representation(inputShapes)); - auto f = ov::test::snippets::TransposeMulFunction(inputShapes, order); + std::tie(inputShapes, order, ref_num_nodes, ref_num_subgraphs, targetDevice) = this->GetParam(); + init_input_shapes({inputShapes.first, inputShapes.second}); + auto f = ov::test::snippets::TransposeMulFunction(inputDynamicShapes, order); function = f.getOriginal(); if (!configuration.count("SNIPPETS_MODE")) { configuration.insert({"SNIPPETS_MODE", "IGNORE_CALLBACK"}); diff --git a/src/tests/functional/plugin/shared/src/snippets/transpose_softmax.cpp b/src/tests/functional/plugin/shared/src/snippets/transpose_softmax.cpp index 322eaa6a14b..739ab83cfd6 100644 --- a/src/tests/functional/plugin/shared/src/snippets/transpose_softmax.cpp +++ b/src/tests/functional/plugin/shared/src/snippets/transpose_softmax.cpp @@ -12,7 +12,7 @@ namespace test { namespace snippets { std::string TransposeSoftmax::getTestCaseName(testing::TestParamInfo obj) { - std::vector inputShapes; + std::vector inputShapes; std::vector order; int axis; std::string targetDevice; @@ -20,8 +20,13 @@ std::string TransposeSoftmax::getTestCaseName(testing::TestParamInfo inputShapes; + std::vector inputShapes; std::vector order; int64_t axis; std::tie(inputShapes, order, axis, ref_num_nodes, ref_num_subgraphs, targetDevice) = this->GetParam(); - init_input_shapes(static_shapes_to_test_representation(inputShapes)); + init_input_shapes(inputShapes); auto f = ov::test::snippets::TransposeSoftmaxFunction(inputDynamicShapes, order, axis); function = f.getOriginal(); @@ -46,11 +51,11 @@ void TransposeSoftmax::SetUp() { } void TransposeSoftmaxEltwise::SetUp() { - std::vector inputShapes; + std::vector inputShapes; std::vector order; int64_t axis; std::tie(inputShapes, order, axis, ref_num_nodes, ref_num_subgraphs, targetDevice) = this->GetParam(); - init_input_shapes(static_shapes_to_test_representation(inputShapes)); + init_input_shapes(inputShapes); auto f = ov::test::snippets::TransposeSoftmaxEltwiseFunction(inputDynamicShapes, order, axis); function = f.getOriginal(); diff --git a/src/tests/ov_helpers/ov_snippets_models/include/subgraph_softmax.hpp b/src/tests/ov_helpers/ov_snippets_models/include/subgraph_softmax.hpp index 92897e7f791..eae6b308c55 100644 --- a/src/tests/ov_helpers/ov_snippets_models/include/subgraph_softmax.hpp +++ b/src/tests/ov_helpers/ov_snippets_models/include/subgraph_softmax.hpp @@ -56,7 +56,9 @@ protected: class TransposeSoftmaxEltwiseFunction : public TransposeSoftmaxFunction { public: explicit TransposeSoftmaxEltwiseFunction(const std::vector& inputShapes, const std::vector& order, const int64_t axis) - : TransposeSoftmaxFunction(inputShapes, order, axis) {} + : TransposeSoftmaxFunction(inputShapes, order, axis) { + OPENVINO_ASSERT(input_shapes.size() == 2, "Got invalid number of input shapes"); + } protected: std::shared_ptr initOriginal() const override; }; diff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp index 1a7d147b75d..16571e1a0cd 100644 --- a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp +++ b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp @@ -78,11 +78,11 @@ std::shared_ptr TransposeSoftmaxEltwiseFunction::initOriginal() const const auto transpose0Param = std::make_shared(precision, input_shapes[0]); const auto transpose0Const = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{m_order.size()}, m_order); const auto transpose2 = std::make_shared(transpose0Param, transpose0Const); - const auto mulConst = ov::test::utils::make_constant(ov::element::f32, transpose2->get_shape()); - const auto mul = std::make_shared(transpose2, mulConst); + const auto mul1Param = std::make_shared(precision, input_shapes[1]); + const auto mul = std::make_shared(transpose2, mul1Param); const auto softMax = std::make_shared(mul, m_axis); const auto hswish = std::make_shared(softMax); - return std::make_shared(ov::NodeVector{hswish}, ov::ParameterVector{transpose0Param}, + return std::make_shared(ov::NodeVector{hswish}, ov::ParameterVector{transpose0Param, mul1Param}, "softmax_transpose"); }