[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
This commit is contained in:
parent
0908908227
commit
1d226d4edc
|
|
@ -44,7 +44,6 @@ std::shared_ptr<Node> Load::clone_with_new_inputs(const OutputVector& new_args)
|
|||
LoadReshape::LoadReshape(const Output<ov::Node>& x, const size_t count, const size_t offset, std::vector<size_t> 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 &&
|
||||
|
|
|
|||
|
|
@ -59,8 +59,7 @@ auto is_supported_op(const std::shared_ptr<const Node> &n) -> bool {
|
|||
};
|
||||
auto is_supported_transpose = [](const std::shared_ptr<const Node>& n) -> bool {
|
||||
const auto& transpose = as_type_ptr<const opset1::Transpose>(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<opset1::MatMul>(parent) || ov::is_type<opset1::MatMul>(child);
|
||||
|
|
|
|||
|
|
@ -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<size_t> 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::op::v0::MatMul>(
|
||||
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::op::v0::MatMul>(ov::pass::pattern::any_input(), ov::pass::pattern::any_input());
|
||||
|
||||
register_matcher(std::make_shared<ov::pass::pattern::Matcher>(m_matmul0, matcher_name),
|
||||
[=](ov::pass::pattern::Matcher &m) {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ FuseTransposeBrgemm::FuseTransposeBrgemm() {
|
|||
const auto& transpose_out = m.get_match_value();
|
||||
const auto& const_order = ov::as_type_ptr<ov::op::v0::Constant>(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<size_t>());
|
||||
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<ov::op::v0::Constant>(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<size_t>());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ TransposeDecomposition::TransposeDecomposition() {
|
|||
const auto transpose = ov::as_type_ptr<ov::opset1::Transpose>(pattern_to_output.at(match_transpose).get_node_shared_ptr());
|
||||
|
||||
const auto order = ov::as_type_ptr<ov::op::v0::Constant>(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<int>();
|
||||
|
|
@ -65,10 +65,14 @@ TransposeDecomposition::TransposeDecomposition() {
|
|||
auto load = std::make_shared<snippets::op::LoadReshape>(data_input, subtensor[0], 0, layout);
|
||||
auto store = std::make_shared<snippets::op::Store>(load, subtensor[0]);
|
||||
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(load->input(0), std::make_shared<PortDescriptor>(load->get_input_shape(0), subtensor, layout));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(load->output(0), std::make_shared<PortDescriptor>(load->get_output_shape(0), subtensor));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(store->input(0), std::make_shared<PortDescriptor>(store->get_input_shape(0), subtensor));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(store->output(0), std::make_shared<PortDescriptor>(store->get_output_shape(0), subtensor));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(load->input(0),
|
||||
std::make_shared<PortDescriptor>(utils::pshape_to_vdims(load->get_input_partial_shape(0)), subtensor, layout));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(load->output(0),
|
||||
std::make_shared<PortDescriptor>(utils::pshape_to_vdims(load->get_output_partial_shape(0)), subtensor));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(store->input(0),
|
||||
std::make_shared<PortDescriptor>(utils::pshape_to_vdims(store->get_input_partial_shape(0)), subtensor));
|
||||
PortDescriptorUtils::set_port_descriptor_ptr(store->output(0),
|
||||
std::make_shared<PortDescriptor>(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));
|
||||
|
|
|
|||
|
|
@ -11,8 +11,26 @@ namespace snippets {
|
|||
|
||||
|
||||
namespace {
|
||||
std::vector<ov::PartialShape> input_shapes_4D{{2, 3, 5, 13}, {2, 3, 2, 4}, {1, 7, 1, 4}};
|
||||
std::vector<ov::PartialShape> input_shapes_3D{{3, 5, 13}, {3, 2, 4}, {7, 1, 4}};
|
||||
|
||||
const std::vector<InputShape> 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<InputShape> 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<std::vector<int32_t>> orders_4D{{0, 2, 3, 1}};
|
||||
std::vector<std::vector<int32_t>> 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<std::pair<InputShape, InputShape>> 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<ov::PartialShape>{{2, 3, 5, 31}}),
|
||||
::testing::ValuesIn(inputShapesPair),
|
||||
::testing::Values(std::vector<int> {0, 2, 3, 1}),
|
||||
::testing::Values(1), // Transpose
|
||||
::testing::Values(1), // Tokenized Transpose
|
||||
|
|
|
|||
|
|
@ -12,13 +12,29 @@ namespace snippets {
|
|||
|
||||
namespace {
|
||||
|
||||
const std::vector<ov::Shape> inputShape = {
|
||||
ov::Shape{1, 128, 3, 16},
|
||||
const std::vector<std::vector<InputShape>> 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<std::vector<InputShape>> 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<int64_t>{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<int64_t>{0, 2, 3, 1}),
|
||||
::testing::Values(-1),
|
||||
::testing::Values(1),
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace test {
|
|||
namespace snippets {
|
||||
|
||||
typedef std::tuple<
|
||||
ov::PartialShape, // Input 0 Shape
|
||||
InputShape, // Input 0 Shape
|
||||
std::vector<int>, // Transpose order
|
||||
size_t, // Expected num nodes
|
||||
size_t, // Expected num subgraphs
|
||||
|
|
@ -19,8 +19,7 @@ typedef std::tuple<
|
|||
> TransposeParams;
|
||||
|
||||
typedef std::tuple<
|
||||
ov::PartialShape, // Input 0 Shape
|
||||
ov::PartialShape, // Input 1 Shape
|
||||
std::pair<InputShape, InputShape>, // Input Shapes
|
||||
std::vector<int>, // Transpose order
|
||||
size_t, // Expected num nodes
|
||||
size_t, // Expected num subgraphs
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ namespace test {
|
|||
namespace snippets {
|
||||
|
||||
typedef std::tuple<
|
||||
std::vector<ov::Shape>, // Input shapes
|
||||
std::vector<InputShape>, // Input shapes
|
||||
std::vector<int64_t>, // Transpose Order
|
||||
int64_t, // Softmax Axis
|
||||
size_t, // Expected num nodes
|
||||
|
|
|
|||
|
|
@ -12,14 +12,14 @@ namespace test {
|
|||
namespace snippets {
|
||||
|
||||
std::string Transpose::getTestCaseName(testing::TestParamInfo<ov::test::snippets::TransposeParams> obj) {
|
||||
ov::PartialShape inputShape;
|
||||
InputShape inputShapes;
|
||||
std::vector<int> 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<ov::test::snippets
|
|||
}
|
||||
|
||||
void Transpose::SetUp() {
|
||||
ov::PartialShape inputShape;
|
||||
InputShape inputShape;
|
||||
std::vector<int> 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<ov::test::snippets::TransposeMulParams> obj) {
|
||||
std::vector<ov::PartialShape> inputShapes(2);
|
||||
std::pair<InputShape, InputShape> inputShapes;
|
||||
std::vector<int> 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<ov::test::snipp
|
|||
}
|
||||
|
||||
void TransposeMul::SetUp() {
|
||||
std::vector<ov::PartialShape> inputShapes(2);
|
||||
std::pair<InputShape, InputShape> inputShapes;
|
||||
std::vector<int> 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"});
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ namespace test {
|
|||
namespace snippets {
|
||||
|
||||
std::string TransposeSoftmax::getTestCaseName(testing::TestParamInfo<ov::test::snippets::TransposeSoftmaxParams> obj) {
|
||||
std::vector<ov::Shape> inputShapes;
|
||||
std::vector<InputShape> inputShapes;
|
||||
std::vector<int64_t> order;
|
||||
int axis;
|
||||
std::string targetDevice;
|
||||
|
|
@ -20,8 +20,13 @@ std::string TransposeSoftmax::getTestCaseName(testing::TestParamInfo<ov::test::s
|
|||
std::tie(inputShapes, order, axis, num_nodes, num_subgraphs, targetDevice) = obj.param;
|
||||
|
||||
std::ostringstream result;
|
||||
for (size_t i = 0; i < inputShapes.size(); ++i)
|
||||
result << "IS[" << i << "]=" << ov::test::utils::vec2str(inputShapes[i]) << "_";
|
||||
for (size_t i = 0; i < inputShapes.size(); ++i) {
|
||||
result << "IS[" << i<< "]=" << ov::test::utils::partialShape2str({inputShapes[i].first}) << "_";
|
||||
result << "TS[" << i<< "]=";
|
||||
for (const auto& shape : inputShapes[i].second) {
|
||||
result << "(" << ov::test::utils::vec2str(shape) << ")_";
|
||||
}
|
||||
}
|
||||
result << "TO=" << ov::test::utils::vec2str(order) << "_";
|
||||
result << "Axis=" << axis << "_";
|
||||
result << "#N=" << num_nodes << "_";
|
||||
|
|
@ -31,11 +36,11 @@ std::string TransposeSoftmax::getTestCaseName(testing::TestParamInfo<ov::test::s
|
|||
}
|
||||
|
||||
void TransposeSoftmax::SetUp() {
|
||||
std::vector<ov::Shape> inputShapes;
|
||||
std::vector<InputShape> inputShapes;
|
||||
std::vector<int64_t> 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<ov::Shape> inputShapes;
|
||||
std::vector<InputShape> inputShapes;
|
||||
std::vector<int64_t> 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();
|
||||
|
|
|
|||
|
|
@ -56,7 +56,9 @@ protected:
|
|||
class TransposeSoftmaxEltwiseFunction : public TransposeSoftmaxFunction {
|
||||
public:
|
||||
explicit TransposeSoftmaxEltwiseFunction(const std::vector<PartialShape>& inputShapes, const std::vector<int64_t>& 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<ov::Model> initOriginal() const override;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ std::shared_ptr<ov::Model> TransposeSoftmaxEltwiseFunction::initOriginal() const
|
|||
const auto transpose0Param = std::make_shared<ov::opset1::Parameter>(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<ov::op::v1::Transpose>(transpose0Param, transpose0Const);
|
||||
const auto mulConst = ov::test::utils::make_constant(ov::element::f32, transpose2->get_shape());
|
||||
const auto mul = std::make_shared<ov::op::v1::Multiply>(transpose2, mulConst);
|
||||
const auto mul1Param = std::make_shared<ov::opset1::Parameter>(precision, input_shapes[1]);
|
||||
const auto mul = std::make_shared<ov::op::v1::Multiply>(transpose2, mul1Param);
|
||||
const auto softMax = std::make_shared<ov::op::v8::Softmax>(mul, m_axis);
|
||||
const auto hswish = std::make_shared<ov::op::v4::HSwish>(softMax);
|
||||
return std::make_shared<ov::Model>(ov::NodeVector{hswish}, ov::ParameterVector{transpose0Param},
|
||||
return std::make_shared<ov::Model>(ov::NodeVector{hswish}, ov::ParameterVector{transpose0Param, mul1Param},
|
||||
"softmax_transpose");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue