OpenVINO™ is an open source toolkit for optimizing and deploying AI inference
C++ aicomputer-visiondeep-learningdeploy-aidiffusion-modelsgenerative-aigood-first-issueinferencellm-inferencenatural-language-processingnlpopenvinooptimize-aiperformance-boostrecommendation-systemspeech-recognitionstable-diffusiontransformersyolo
[Snippets]Online softmax decomposition on data flow (#31932)
Chenhu Wangf49142a9a5a8
diff --git a/src/common/snippets/include/snippets/op/online_softmax.hpp b/src/common/snippets/include/snippets/op/online_softmax.hppnew file mode 100644index 00000000000..19366dad649--- /dev/null+++ b/src/common/snippets/include/snippets/op/online_softmax.hpp@@ -0,0 +1,29 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"++namespace ov::snippets::op {++/**+ * @interface OnlineSoftmax+ * @brief OnlineSoftmax is a softmax that evaluate with online manner with axis on last dimension.+ * @ingroup snippets+ */+class OnlineSoftmax : public ov::op::Op {+public:+ OPENVINO_OP("OnlineSoftmax", "SnippetsOpset");++ explicit OnlineSoftmax(const Output<Node>& x);+ OnlineSoftmax() = default;++ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;+ void validate_and_infer_types() override;+};++} // namespace ov::snippets::op\ No newline at end of filediff --git a/src/common/snippets/include/snippets/op/online_softmax_update_max.hpp b/src/common/snippets/include/snippets/op/online_softmax_update_max.hppnew file mode 100644index 00000000000..1725970a357--- /dev/null+++ b/src/common/snippets/include/snippets/op/online_softmax_update_max.hpp@@ -0,0 +1,46 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <cstddef>+#include <memory>+#include <utility>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"++namespace ov::snippets::op {++/**+ * @interface OnlineSoftmaxUpdateMax+ * @brief OnlineSoftmaxUpdateMax handles the current max computation and update parts in online softmax algo.+ * @ingroup snippets+ * scheme:+ * ---------------+ * | |+ * | \|/+ * | Input Buffer+ * | \ / |+ * ------- Max |+ * | \ /+ * | Sub+ * | |+ * Result0 Result1+ *+ * Note that Buffer must be updated with the Max result only after Sub from control flow perspective.+ */+class OnlineSoftmaxUpdateMax : public ov::op::Op {+public:+ OPENVINO_OP("OnlineSoftmaxUpdateMax", "SnippetsOpset");++ explicit OnlineSoftmaxUpdateMax(const Output<Node>& max_local);+ OnlineSoftmaxUpdateMax() = default;++ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;+ void validate_and_infer_types() override;+};++} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/op/online_softmax_update_sum.hpp b/src/common/snippets/include/snippets/op/online_softmax_update_sum.hppnew file mode 100644index 00000000000..9f7cb291679--- /dev/null+++ b/src/common/snippets/include/snippets/op/online_softmax_update_sum.hpp@@ -0,0 +1,41 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include <cstddef>+#include <memory>+#include <utility>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"++namespace ov::snippets::op {++/**+ * @interface OnlineSoftmaxUpdateSum+ * @brief OnlineSoftmaxUpdateSum handles the current sum computation and update parts in online softmax algo.+ * @ingroup snippets+ * scheme:+ * -----> Buffer In1 In0(sum_local)+ * | \ / |+ * | Result1---Mul |+ * | \ /+ * ---------------Add+ * |+ * Result0+ */+class OnlineSoftmaxUpdateSum : public ov::op::Op {+public:+ OPENVINO_OP("OnlineSoftmaxUpdateSum", "SnippetsOpset");++ explicit OnlineSoftmaxUpdateSum(const Output<Node>& sum_local, const Output<Node>& coeff);+ OnlineSoftmaxUpdateSum() = default;++ std::shared_ptr<Node> clone_with_new_inputs(const OutputVector& new_args) const override;+ void validate_and_infer_types() override;+};++} // namespace ov::snippets::opdiff --git a/src/common/snippets/include/snippets/pass/online_softmax_decomposition.hpp b/src/common/snippets/include/snippets/pass/online_softmax_decomposition.hppnew file mode 100644index 00000000000..e0440bab13b--- /dev/null+++ b/src/common/snippets/include/snippets/pass/online_softmax_decomposition.hpp@@ -0,0 +1,46 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "openvino/pass/matcher_pass.hpp"++namespace ov::snippets::pass {++/**+ * @interface OnlineSoftmaxDecomposition+ * @brief Decomposes OnlineSoftmax to a range of low-level operations.+ * @ingroup snippets+ * scheme:+ * Decompose OnlineSoftmax to below subgraph:+ * -----------Input+ * | |+ * | ReduceMax+ * | |+ * | OnlineSoftmaxUpdateMax+ * | | |+ * ----------Subtract |+ * | |+ * ------------Exp Exp+ * | | |+ * | ReduceSum |+ * | | |+ * | OnlineSoftmaxUpdateSum+ * | |\ |+ * | | \ |+ * | | \ |+ * | | \ |+ * | Power Divide+ * | | |+ * ----------Multiply Result1+ * |+ * Result0+ */+class OnlineSoftmaxDecomposition : public ov::pass::MatcherPass {+public:+ OPENVINO_MATCHER_PASS_RTTI("snippets::pass::OnlineSoftmaxDecomposition");+ OnlineSoftmaxDecomposition();+};++} // namespace ov::snippets::passdiff --git a/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp b/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hppindex 1ee8418be51..17c7888ec45 100644--- a/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp+++ b/src/common/snippets/include/snippets/shape_inference/shape_infer_instances.hpp@@ -37,10 +37,14 @@ public:};class PassThroughShapeInfer : public IShapeInferSnippets {+ size_t m_output_num;+public:+ explicit PassThroughShapeInfer(const size_t& output_num = 1) : m_output_num(output_num) {}Result infer(const std::vector<VectorDimsRef>& input_shapes) override {OPENVINO_ASSERT(!input_shapes.empty(), "Empty Input shapes are not allowed for PassThroughShapeInfer");- return {{input_shapes[0].get()}, ShapeInferStatus::success};+ std::vector<VectorDims> output_shapes(m_output_num, input_shapes[0].get());+ return {output_shapes, ShapeInferStatus::success};}};@@ -87,4 +91,14 @@ public:Result infer(const std::vector<VectorDimsRef>& input_shapes) override;};+class OnlineSoftmaxShapeInfer : public IShapeInferSnippets {+public:+ Result infer(const std::vector<VectorDimsRef>& input_shapes) override {+ OPENVINO_ASSERT(input_shapes.size() == 1, "Invalid number of shapes to OnlineSoftmaxShapeInfer.");+ auto coeff_shape = input_shapes[0].get();+ coeff_shape.back() = 1;+ return {{input_shapes[0].get(), coeff_shape}, ShapeInferStatus::success};+ }+};+} // namespace ov::snippetsdiff --git a/src/common/snippets/src/op/online_softmax.cpp b/src/common/snippets/src/op/online_softmax.cppnew file mode 100644index 00000000000..59b98b84f9c--- /dev/null+++ b/src/common/snippets/src/op/online_softmax.cpp@@ -0,0 +1,34 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "snippets/op/online_softmax.hpp"++#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"+#include "snippets/itt.hpp"++namespace ov::snippets::op {++OnlineSoftmax::OnlineSoftmax(const Output<Node>& x) : Op({x}) {+ constructor_validate_and_infer_types();+}++std::shared_ptr<Node> OnlineSoftmax::clone_with_new_inputs(const OutputVector& new_args) const {+ INTERNAL_OP_SCOPE(OnlineSoftmax);+ check_new_args_count(this, new_args);+ return std::make_shared<OnlineSoftmax>(new_args.at(0));+}++void OnlineSoftmax::validate_and_infer_types() {+ auto input_shape = get_input_partial_shape(0);+ set_output_type(0, get_input_element_type(0), input_shape);+ const auto& rank = input_shape.size();+ input_shape[rank - 1] = 1;+ set_output_type(1, get_input_element_type(0), input_shape);+}++} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/online_softmax_update_max.cpp b/src/common/snippets/src/op/online_softmax_update_max.cppnew file mode 100644index 00000000000..de24d0e9e4f--- /dev/null+++ b/src/common/snippets/src/op/online_softmax_update_max.cpp@@ -0,0 +1,31 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "snippets/op/online_softmax_update_max.hpp"++#include <memory>++#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"+#include "snippets/itt.hpp"++namespace ov::snippets::op {++OnlineSoftmaxUpdateMax::OnlineSoftmaxUpdateMax(const Output<Node>& max_local) : Op({max_local}) {+ constructor_validate_and_infer_types();+}++std::shared_ptr<Node> OnlineSoftmaxUpdateMax::clone_with_new_inputs(const OutputVector& new_args) const {+ INTERNAL_OP_SCOPE(OnlineSoftmaxUpdateMax);+ check_new_args_count(this, new_args);+ return std::make_shared<OnlineSoftmaxUpdateMax>(new_args.at(0));+}++void OnlineSoftmaxUpdateMax::validate_and_infer_types() {+ set_output_type(0, get_input_element_type(0), get_input_partial_shape(0));+ set_output_type(1, get_input_element_type(0), get_input_partial_shape(0));+}++} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/op/online_softmax_update_sum.cpp b/src/common/snippets/src/op/online_softmax_update_sum.cppnew file mode 100644index 00000000000..c7b24858a88--- /dev/null+++ b/src/common/snippets/src/op/online_softmax_update_sum.cpp@@ -0,0 +1,35 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "snippets/op/online_softmax_update_sum.hpp"++#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/node.hpp"+#include "openvino/core/node_output.hpp"+#include "openvino/op/op.hpp"+#include "snippets/itt.hpp"++namespace ov::snippets::op {++OnlineSoftmaxUpdateSum::OnlineSoftmaxUpdateSum(const Output<Node>& sum_local, const Output<Node>& coeff)+ : Op({sum_local, coeff}) {+ constructor_validate_and_infer_types();+}++std::shared_ptr<Node> OnlineSoftmaxUpdateSum::clone_with_new_inputs(const OutputVector& new_args) const {+ INTERNAL_OP_SCOPE(OnlineSoftmaxUpdateSum);+ check_new_args_count(this, new_args);+ return std::make_shared<OnlineSoftmaxUpdateSum>(new_args.at(0), new_args.at(1));+}++void OnlineSoftmaxUpdateSum::validate_and_infer_types() {+ OPENVINO_ASSERT(get_input_partial_shape(0) == get_input_partial_shape(1),+ "Two inputs of OnlineSoftmaxUpdateSum must have the same shape.");+ set_output_type(0, get_input_element_type(0), get_input_partial_shape(0));+ set_output_type(1, get_input_element_type(0), get_input_partial_shape(0));+}++} // namespace ov::snippets::opdiff --git a/src/common/snippets/src/pass/online_softmax_decomposition.cpp b/src/common/snippets/src/pass/online_softmax_decomposition.cppnew file mode 100644index 00000000000..9a057fbeceb--- /dev/null+++ b/src/common/snippets/src/pass/online_softmax_decomposition.cpp@@ -0,0 +1,98 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include "snippets/pass/online_softmax_decomposition.hpp"++#include <memory>++#include "openvino/core/except.hpp"+#include "openvino/core/rt_info.hpp"+#include "openvino/core/type.hpp"+#include "openvino/core/type/element_type.hpp"+#include "openvino/op/divide.hpp"+#include "openvino/op/exp.hpp"+#include "openvino/op/multiply.hpp"+#include "openvino/op/subtract.hpp"+#include "openvino/pass/matcher_pass.hpp"+#include "openvino/pass/pattern/matcher.hpp"+#include "openvino/pass/pattern/op/label.hpp"+#include "openvino/pass/pattern/op/pattern.hpp"+#include "openvino/pass/pattern/op/wrap_type.hpp"+#include "snippets/itt.hpp"+#include "snippets/op/online_softmax.hpp"+#include "snippets/op/online_softmax_update_max.hpp"+#include "snippets/op/online_softmax_update_sum.hpp"+#include "snippets/op/powerstatic.hpp"+#include "snippets/op/reduce.hpp"++namespace ov::snippets::pass {++OnlineSoftmaxDecomposition::OnlineSoftmaxDecomposition() {+ MATCHER_SCOPE(OnlineSoftmaxDecomposition);++ using namespace ov::pass::pattern;+ const auto online_softmax_m = wrap_type<ov::snippets::op::OnlineSoftmax>({any_input()});++ ov::matcher_pass_callback callback = [=](ov::pass::pattern::Matcher& m) {+ OV_ITT_SCOPED_TASK(ov::pass::itt::domains::SnippetsTransform, "Snippets::op::OnlineSoftmaxDecomposition")+ const auto& online_softmax = ov::as_type_ptr<ov::snippets::op::OnlineSoftmax>(m.get_match_root());++ OPENVINO_ASSERT(online_softmax->get_input_element_type(0).is_real(),+ "OnlineSoftmaxDecomposition currently only works for real data type");++ const auto& pshape = online_softmax->get_input_partial_shape(0);+ OPENVINO_ASSERT(!pshape.rank().is_dynamic(), "OnlineSoftmaxDecomposition doesn't support dynamic ranks");+ const auto& rank = pshape.size();+ OPENVINO_ASSERT(rank != 0, "OnlineSoftmaxDecomposition doesn't support input tesnor with rank smaller than 1");++ const auto& axis = rank - 1;++ const auto& softmax_input = online_softmax->input_value(0);+ const auto& reduce_max = std::make_shared<ov::snippets::op::ReduceMax>(softmax_input, axis);++ // input is max_local, first output is max_current, second ouput is (max_past - max_current)+ const auto& updated_max = std::make_shared<ov::snippets::op::OnlineSoftmaxUpdateMax>(reduce_max);++ // sum_local+ const auto& subtract = std::make_shared<ov::op::v1::Subtract>(softmax_input, updated_max->output(0));+ const auto& exp = std::make_shared<ov::op::v0::Exp>(subtract);+ const auto& reduce_sum = std::make_shared<ov::snippets::op::ReduceSum>(exp, axis);++ // std::exp(max_past - max)+ const auto& coeff_exp = std::make_shared<ov::op::v0::Exp>(updated_max->output(1));+ // sum_current = std::exp(max_past - max) * sum_past + sum_local+ // output 0 is sum_current.+ // output 1 is coeff(std::exp(max_past - max) * sum_past) to second brgemm, not used in single online softmax.+ const auto& updated_sum = std::make_shared<ov::snippets::op::OnlineSoftmaxUpdateSum>(reduce_sum, coeff_exp);+ const auto& power = std::make_shared<ov::snippets::op::PowerStatic>(updated_sum->output(0), -1.F);+ const auto& multiply = std::make_shared<ov::op::v1::Multiply>(exp, power);++ // This is coeff for second brgemm in flash attention scenario (it is applied on the K loops exception+ // the first iteration).+ // It is not used in single online softmax scenario.+ // std::exp(max_past - max) * sum_past / sum_current+ const auto& brgemm_coeff = std::make_shared<ov::op::v1::Divide>(updated_sum->output(1), updated_sum->output(0));++ copy_runtime_info(online_softmax,+ {reduce_max,+ updated_max,+ subtract,+ exp,+ reduce_sum,+ coeff_exp,+ updated_sum,+ power,+ multiply,+ brgemm_coeff});+ multiply->set_friendly_name(online_softmax->get_friendly_name());+ online_softmax->output(0).replace(multiply->output(0));+ online_softmax->output(1).replace(brgemm_coeff->output(0));+ return true;+ };++ auto m = std::make_shared<ov::pass::pattern::Matcher>(online_softmax_m, matcher_name);+ register_matcher(m, callback);+}++} // namespace ov::snippets::pass\ No newline at end of filediff --git a/src/common/snippets/src/shape_inference/shape_inference.cpp b/src/common/snippets/src/shape_inference/shape_inference.cppindex cf14ed94333..55b4ba63e00 100644--- a/src/common/snippets/src/shape_inference/shape_inference.cpp+++ b/src/common/snippets/src/shape_inference/shape_inference.cpp@@ -31,6 +31,9 @@#include "snippets/op/load.hpp"#include "snippets/op/loop.hpp"#include "snippets/op/nop.hpp"+#include "snippets/op/online_softmax.hpp"+#include "snippets/op/online_softmax_update_max.hpp"+#include "snippets/op/online_softmax_update_sum.hpp"#include "snippets/op/perf_count.hpp"#include "snippets/op/rank_normalization.hpp"#include "snippets/op/reduce.hpp"@@ -59,9 +62,9 @@ ShapeInferPtr IShapeInferSnippetsFactory::get_specific_op_shape_infer(return {};}-#define SHAPE_INFER_PREDEFINED(OP, InferType) \+#define SHAPE_INFER_PREDEFINED(OP, InferType, ...) \{OP::get_type_info_static(), []([[maybe_unused]] const std::shared_ptr<ov::Node>& n) { \- return std::make_shared<InferType>(); \+ return std::make_shared<InferType>(__VA_ARGS__); \}}#define SHAPE_INFER_OP_SPECIFIC(OP) \{OP::get_type_info_static(), [](const std::shared_ptr<ov::Node>& n) { \@@ -83,6 +86,9 @@ const IShapeInferSnippetsFactory::TRegistry IShapeInferSnippetsFactory::registrySHAPE_INFER_PREDEFINED(ov::op::v0::PRelu, PassThroughShapeInfer),SHAPE_INFER_PREDEFINED(op::HorizonMax, HorizonOpShapeInfer),SHAPE_INFER_PREDEFINED(op::HorizonSum, HorizonOpShapeInfer),+ SHAPE_INFER_PREDEFINED(op::OnlineSoftmax, OnlineSoftmaxShapeInfer),+ SHAPE_INFER_PREDEFINED(op::OnlineSoftmaxUpdateMax, PassThroughShapeInfer, 2),+ SHAPE_INFER_PREDEFINED(op::OnlineSoftmaxUpdateSum, PassThroughShapeInfer, 2),//SHAPE_INFER_PREDEFINED(op::Scalar, SingleElementShapeInfer),SHAPE_INFER_PREDEFINED(op::VectorBuffer, SingleElementShapeInfer),diff --git a/src/common/snippets/tests/include/pass/online_softmax_decomposition.hpp b/src/common/snippets/tests/include/pass/online_softmax_decomposition.hppnew file mode 100644index 00000000000..790e8b4241f--- /dev/null+++ b/src/common/snippets/tests/include/pass/online_softmax_decomposition.hpp@@ -0,0 +1,28 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#pragma once++#include "lowering_utils.hpp"+#include "subgraph_softmax.hpp"++namespace ov {+namespace test {+namespace snippets {++typedef std::tuple<+ PartialShape // Input shape+> OnlineSoftmaxDecompositionTestParams;++class OnlineSoftmaxDecompositionTest : public LoweringTests, public testing::WithParamInterface<OnlineSoftmaxDecompositionTestParams> {+public:+ static std::string getTestCaseName(testing::TestParamInfo<OnlineSoftmaxDecompositionTestParams> obj);+protected:+ void SetUp() override;+ std::shared_ptr<SnippetsFunctionBase> snippets_model;+};++} // namespace snippets+} // namespace test+} // namespace ovdiff --git a/src/common/snippets/tests/src/pass/online_softmax_decomposition.cpp b/src/common/snippets/tests/src/pass/online_softmax_decomposition.cppnew file mode 100644index 00000000000..5e3fbdfd8e2--- /dev/null+++ b/src/common/snippets/tests/src/pass/online_softmax_decomposition.cpp@@ -0,0 +1,46 @@+// Copyright (C) 2018-2025 Intel Corporation+// SPDX-License-Identifier: Apache-2.0+//++#include <gtest/gtest.h>+#include "pass/online_softmax_decomposition.hpp"+#include "snippets/pass/online_softmax_decomposition.hpp"+#include "common_test_utils/common_utils.hpp"+#include "subgraph_softmax.hpp"+#include "subgraph_lowered.hpp"++namespace ov {+namespace test {+namespace snippets {++std::string OnlineSoftmaxDecompositionTest::getTestCaseName(testing::TestParamInfo<OnlineSoftmaxDecompositionTestParams> obj) {+ std::ostringstream result;+ result << "IS=" << std::get<0>(obj.param);+ return result.str();+}++void OnlineSoftmaxDecompositionTest::SetUp() {+ LoweringTests::SetUp();+ std::vector<PartialShape> input_shapes{std::get<0>(this->GetParam())};++ snippets_model = std::make_shared<OnlineSoftmaxFunction>(input_shapes);+ manager.register_pass<ov::snippets::pass::OnlineSoftmaxDecomposition>();+}++TEST_P(OnlineSoftmaxDecompositionTest, OnlineSoftmaxDecomposition) {+ model = snippets_model->getOriginal();+ model_ref = snippets_model->getReference();+}++namespace OnlineSoftmaxDecompositionTestInstantiation {+const std::vector<ov::PartialShape> input_shapes{{2, 2, 64, 4096}, {1, 3, 128}, {4, 64}, {32}};++INSTANTIATE_TEST_SUITE_P(smoke_Snippets_OnlineSoftmaxDecomposition,+ OnlineSoftmaxDecompositionTest,+ ::testing::Combine(::testing::ValuesIn(input_shapes)),+ OnlineSoftmaxDecompositionTest::getTestCaseName);++} // namespace OnlineSoftmaxDecompositionTestInstantiation+} // namespace snippets+} // namespace test+} // namespace ovdiff --git a/src/tests/ov_helpers/ov_snippets_models/include/subgraph_softmax.hpp b/src/tests/ov_helpers/ov_snippets_models/include/subgraph_softmax.hppindex 29f4ecce03a..6983c30a2ca 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@@ -73,6 +73,18 @@ protected:int axis;};+class OnlineSoftmaxFunction : public SnippetsFunctionBase {+public:+ explicit OnlineSoftmaxFunction(const std::vector<PartialShape>& inputShapes)+ : SnippetsFunctionBase(inputShapes) {+ OPENVINO_ASSERT(input_shapes.size() == 1, "Got invalid number of input shapes");+ }++protected:+ std::shared_ptr<ov::Model> initOriginal() const override;+ std::shared_ptr<ov::Model> initReference() const override;+};+} // namespace snippets} // namespace test} // namespace ovdiff --git a/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cpp b/src/tests/ov_helpers/ov_snippets_models/src/subgraph_softmax.cppindex da9dc8f4df4..46228c68b92 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@@ -9,6 +9,9 @@#include <snippets/op/subgraph.hpp>#include <snippets/op/reduce.hpp>#include <snippets/op/powerstatic.hpp>+#include <snippets/op/online_softmax.hpp>+#include <snippets/op/online_softmax_update_max.hpp>+#include <snippets/op/online_softmax_update_sum.hpp>#include "openvino/core/validation_util.hpp"namespace ov {@@ -101,6 +104,35 @@ std::shared_ptr<ov::Model> SoftmaxSumFunction::initOriginal() const {return std::make_shared<ov::Model>(OutputVector{add}, ParameterVector{data0, data1});}+std::shared_ptr<ov::Model> OnlineSoftmaxFunction::initOriginal() const {+ auto data = std::make_shared<op::v0::Parameter>(precision, input_shapes[0]);+ const auto online_softmax = std::make_shared<ov::snippets::op::OnlineSoftmax>(data);+ return std::make_shared<ov::Model>(OutputVector{online_softmax->output(0), online_softmax->output(1)},+ ParameterVector{data});+}++std::shared_ptr<ov::Model> OnlineSoftmaxFunction::initReference() const {+ auto data = std::make_shared<op::v0::Parameter>(precision, input_shapes[0]);+ const auto axis = input_shapes[0].size() - 1;++ const auto reduce_max = std::make_shared<ov::snippets::op::ReduceMax>(data, axis);+ const auto updated_max = std::make_shared<ov::snippets::op::OnlineSoftmaxUpdateMax>(reduce_max);++ const auto subtract = std::make_shared<ov::op::v1::Subtract>(data, updated_max->output(0));+ const auto exp = std::make_shared<ov::op::v0::Exp>(subtract);+ const auto reduce_sum = std::make_shared<ov::snippets::op::ReduceSum>(exp, axis);++ const auto coeff_exp = std::make_shared<ov::op::v0::Exp>(updated_max->output(1));++ const auto updated_sum = std::make_shared<ov::snippets::op::OnlineSoftmaxUpdateSum>(reduce_sum, coeff_exp);+ const auto power = std::make_shared<ov::snippets::op::PowerStatic>(updated_sum->output(0), -1.F);+ const auto multiply = std::make_shared<ov::op::v1::Multiply>(exp, power);++ const auto brgemm_coeff = std::make_shared<ov::op::v1::Divide>(updated_sum->output(1), updated_sum->output(0));++ return std::make_shared<ov::Model>(OutputVector{multiply, brgemm_coeff}, ParameterVector{data});+}+} // namespace snippets} // namespace test} // namespace ov