Skip to content

OpenVINO™ is an open source toolkit for optimizing and deploying AI inference

Add RMSNormalization & RotaryEmbedding (opset 23) and shared decomposition helpers (#35545)

Maxim Vafind802d32ac0c5
diff --git a/docs/articles_en/documentation/compatibility-and-support/supported-operations.rst b/docs/articles_en/documentation/compatibility-and-support/supported-operations.rst
index 83384923fb3..346724fb029 100644
--- a/docs/articles_en/documentation/compatibility-and-support/supported-operations.rst
+++ b/docs/articles_en/documentation/compatibility-and-support/supported-operations.rst
@@ -211,8 +211,10 @@ Data as of OpenVINO 2025.4.1 (December 18, 2025).
Reshape
Resize
ReverseSequence
+ RMSNormalization
RNN
RoiAlign
+ RotaryEmbedding
Round
Scan
ScatterElements
diff --git a/src/common/transformations/include/openvino/decompositions/rms_norm.hpp b/src/common/transformations/include/openvino/decompositions/rms_norm.hpp
new file mode 100644
index 00000000000..d82c5d30f35
--- /dev/null
+++ b/src/common/transformations/include/openvino/decompositions/rms_norm.hpp
@@ -0,0 +1,47 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/core/node.hpp"
+#include "openvino/core/node_output.hpp"
+#include "openvino/pass/node_registry.hpp"
+#include "transformations_visibility.hpp"
+
+namespace ov {
+namespace decomposition {
+
+/// \brief Build a reference RMSNorm decomposition matched by ov::pass::RMSFusion.
+///
+/// The returned sub-graph implements:
+/// y = x * Power(Sqrt(ReduceMean(x^2, axes) + eps), -1) // when scale is empty
+/// y = scale * (x * Power(Sqrt(ReduceMean(x^2, axes) + eps), -1)) // when scale is provided
+///
+/// The shape of the resulting graph is intentionally aligned with the pattern
+/// detected by ov::pass::RMSFusion so that this decomposition is always fused
+/// back into ov::op::internal::RMS during plugin compilation. This is the
+/// canonical building block to be used by frontends (e.g. PyTorch aten::rms_norm)
+/// instead of emitting a hand-rolled sub-graph.
+///
+/// All nodes created by the helper are added to \p reg so the caller can
+/// post-process them uniformly (e.g. PyTorch frontend iterates the registry
+/// and calls NodeContext::mark_node on each entry).
+///
+/// \param reg Node registry that collects every node created by the helper.
+/// \param x Normalized input tensor.
+/// \param axes Reduction axes for ReduceMean. RMSFusion currently fuses only
+/// the last-dimension reduction (axes constant with a single
+/// element equal to -1 or rank-1).
+/// \param eps Scalar epsilon constant added before the square root. Should
+/// share element type with \p x.
+/// \param scale Optional scaling tensor (gamma). Pass an empty Output to skip
+/// the trailing multiplication.
+ov::Output<ov::Node> TRANSFORMATIONS_API rms_norm(ov::pass::NodeRegistry& reg,
+ const ov::Output<ov::Node>& x,
+ const ov::Output<ov::Node>& axes,
+ const ov::Output<ov::Node>& eps,
+ const ov::Output<ov::Node>& scale = {});
+
+} // namespace decomposition
+} // namespace ov
diff --git a/src/common/transformations/include/openvino/decompositions/rope.hpp b/src/common/transformations/include/openvino/decompositions/rope.hpp
new file mode 100644
index 00000000000..239ec7711cb
--- /dev/null
+++ b/src/common/transformations/include/openvino/decompositions/rope.hpp
@@ -0,0 +1,50 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include <cstdint>
+
+#include "openvino/core/node.hpp"
+#include "openvino/core/node_output.hpp"
+#include "openvino/pass/node_registry.hpp"
+#include "transformations_visibility.hpp"
+
+namespace ov {
+namespace decomposition {
+
+/// \brief Build the canonical (simplest) RoPE decomposition that is
+/// guaranteed to be fused by ov::pass::RoPEFusion into
+/// ov::op::internal::RoPE.
+///
+/// The returned sub-graph implements (along the last axis):
+/// first_half, second_half = split(x, 2)
+/// first_ = first_half * cos - second_half * sin
+/// second_ = second_half * cos + first_half * sin
+/// y = concat(first_, second_, axis=-1)
+///
+/// The negation is expressed as Multiply(-1) + Add (not Subtract) because that
+/// is the exact pattern the RoPEFusion matcher accepts.
+///
+/// All nodes created by the helper are added to \p reg so the caller can
+/// post-process them uniformly (e.g. PyTorch frontend iterates the registry
+/// and calls NodeContext::mark_node on each entry).
+///
+/// Frontends (e.g. ONNX com.microsoft.RotaryEmbedding) are expected to call
+/// this helper for the core formula and add their own pre/post-processing
+/// (position_ids gather, interleaved-mode shuffle, 3D<->4D layout conversion).
+///
+/// \param reg Node registry that collects every node created by the helper.
+/// \param x 4-D input tensor of shape [bs, num_heads, seqlen, head_size].
+/// \param cos Cosine cache broadcastable to [?, 1, ?, head_size/2].
+/// \param sin Sine cache broadcastable to [?, 1, ?, head_size/2].
+/// \param half_head_size Number of element pairs per head, i.e. head_size / 2.
+ov::Output<ov::Node> TRANSFORMATIONS_API rope(ov::pass::NodeRegistry& reg,
+ const ov::Output<ov::Node>& x,
+ const ov::Output<ov::Node>& cos,
+ const ov::Output<ov::Node>& sin,
+ int64_t half_head_size);
+
+} // namespace decomposition
+} // namespace ov
diff --git a/src/common/transformations/src/decompositions/rms_norm.cpp b/src/common/transformations/src/decompositions/rms_norm.cpp
new file mode 100644
index 00000000000..fce8fc5e99a
--- /dev/null
+++ b/src/common/transformations/src/decompositions/rms_norm.cpp
@@ -0,0 +1,41 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "openvino/decompositions/rms_norm.hpp"
+
+#include "openvino/op/add.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/power.hpp"
+#include "openvino/op/reduce_mean.hpp"
+#include "openvino/op/sqrt.hpp"
+#include "utils.hpp"
+
+namespace ov {
+namespace decomposition {
+
+using detail::typed_scalar;
+
+ov::Output<ov::Node> rms_norm(ov::pass::NodeRegistry& reg,
+ const ov::Output<ov::Node>& x,
+ const ov::Output<ov::Node>& axes,
+ const ov::Output<ov::Node>& eps,
+ const ov::Output<ov::Node>& scale) {
+ // Decomposition shape:
+ // y = x * Power(Sqrt(ReduceMean(x^2, axes) + eps), -1) [* scale]
+ // This exact graph is recognised by ov::pass::RMSFusion.
+ auto squared = reg.make<ov::op::v1::Power>(x, typed_scalar(reg, x, 2.0f));
+ auto mean = reg.make<ov::op::v1::ReduceMean>(squared, axes, /*keep_dims=*/true);
+ auto mean_plus_eps = reg.make<ov::op::v1::Add>(mean, eps);
+ auto sqrt = reg.make<ov::op::v0::Sqrt>(mean_plus_eps);
+ auto inv_rms = reg.make<ov::op::v1::Power>(sqrt, typed_scalar(reg, x, -1.0f));
+
+ ov::Output<ov::Node> result = reg.make<ov::op::v1::Multiply>(x, inv_rms);
+ if (scale.get_node_shared_ptr()) {
+ result = reg.make<ov::op::v1::Multiply>(scale, result);
+ }
+ return result;
+}
+
+} // namespace decomposition
+} // namespace ov
diff --git a/src/common/transformations/src/decompositions/rope.cpp b/src/common/transformations/src/decompositions/rope.cpp
new file mode 100644
index 00000000000..aa5d17101fe
--- /dev/null
+++ b/src/common/transformations/src/decompositions/rope.cpp
@@ -0,0 +1,51 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "openvino/decompositions/rope.hpp"
+
+#include "openvino/op/add.hpp"
+#include "openvino/op/concat.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/variadic_split.hpp"
+#include "utils.hpp"
+
+namespace ov {
+namespace decomposition {
+
+ov::Output<ov::Node> rope(ov::pass::NodeRegistry& reg,
+ const ov::Output<ov::Node>& x,
+ const ov::Output<ov::Node>& cos,
+ const ov::Output<ov::Node>& sin,
+ int64_t half_head_size) {
+ // Split x along the last axis into two equal halves of size `half_head_size`.
+ auto split_axis = reg.make<ov::op::v0::Constant>(ov::element::i64, ov::Shape{}, std::vector<int64_t>{-1});
+ auto split_lengths = reg.make<ov::op::v0::Constant>(ov::element::i64,
+ ov::Shape{2},
+ std::vector<int64_t>{half_head_size, half_head_size});
+ auto halves = reg.make<ov::op::v1::VariadicSplit>(x, split_axis, split_lengths)->outputs();
+ const auto& first_half = halves[0];
+ const auto& second_half = halves[1];
+
+ // Core RoPE formula:
+ // first_ = first_half * cos - second_half * sin
+ // second_ = second_half * cos + first_half * sin
+ // The "minus" is expressed as Multiply(-1) + Add (not Subtract) so the
+ // RoPEFusion pattern matcher recognises it.
+ auto first_half_mul_cos = reg.make<ov::op::v1::Multiply>(first_half, cos);
+ auto second_half_mul_sin = reg.make<ov::op::v1::Multiply>(second_half, sin);
+
+ auto neg_one = detail::typed_scalar(reg, x, -1.0f);
+ auto neg_second_half_mul_sin = reg.make<ov::op::v1::Multiply>(second_half_mul_sin, neg_one);
+ auto first_part = reg.make<ov::op::v1::Add>(first_half_mul_cos, neg_second_half_mul_sin);
+
+ auto second_half_mul_cos = reg.make<ov::op::v1::Multiply>(second_half, cos);
+ auto first_half_mul_sin = reg.make<ov::op::v1::Multiply>(first_half, sin);
+ auto second_part = reg.make<ov::op::v1::Add>(second_half_mul_cos, first_half_mul_sin);
+
+ return reg.make<ov::op::v0::Concat>(ov::NodeVector{first_part, second_part}, /*axis=*/-1);
+}
+
+} // namespace decomposition
+} // namespace ov
diff --git a/src/common/transformations/src/decompositions/utils.hpp b/src/common/transformations/src/decompositions/utils.hpp
new file mode 100644
index 00000000000..4cb85877c71
--- /dev/null
+++ b/src/common/transformations/src/decompositions/utils.hpp
@@ -0,0 +1,33 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#pragma once
+
+#include "openvino/core/node.hpp"
+#include "openvino/core/node_output.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/convert_like.hpp"
+#include "openvino/pass/node_registry.hpp"
+
+namespace ov {
+namespace decomposition {
+namespace detail {
+
+// Create a scalar constant typed as `x` so that pattern matchers in the
+// corresponding fusion transformations (which expect a raw `Constant` or
+// `Convert(Constant)`, not `ConvertLike`) can recognise the sub-graph.
+inline ov::Output<ov::Node> typed_scalar(ov::pass::NodeRegistry& reg,
+ const ov::Output<ov::Node>& x,
+ float value) {
+ const auto& et = x.get_element_type();
+ if (et.is_static() && et != ov::element::dynamic) {
+ return reg.make<ov::op::v0::Constant>(et, ov::Shape{}, std::vector<float>{value});
+ }
+ auto c = reg.make<ov::op::v0::Constant>(ov::element::f32, ov::Shape{}, std::vector<float>{value});
+ return reg.make<ov::op::v1::ConvertLike>(c, x);
+}
+
+} // namespace detail
+} // namespace decomposition
+} // namespace ov
diff --git a/src/common/transformations/tests/decompositions/rms_norm_decomposition_fuse_test.cpp b/src/common/transformations/tests/decompositions/rms_norm_decomposition_fuse_test.cpp
new file mode 100644
index 00000000000..e29951d9d6c
--- /dev/null
+++ b/src/common/transformations/tests/decompositions/rms_norm_decomposition_fuse_test.cpp
@@ -0,0 +1,55 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Tests that verify reference decompositions stored in
+// `src/common/decompositions/` are always recognised and folded back into
+// their corresponding internal fused op by the matching transformation.
+//
+// These tests act as a guard for both directions:
+// * decomposition authors must keep the produced sub-graph fusable;
+// * fusion authors must keep accepting the canonical decomposition shape.
+
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "common_test_utils/ov_test_utils.hpp"
+#include "openvino/core/model.hpp"
+#include "openvino/decompositions/rms_norm.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/pass/manager.hpp"
+#include "ov_ops/rms.hpp"
+#include "transformations/common_optimizations/rms_fusion.hpp"
+
+using namespace testing;
+using namespace ov::pass;
+
+TEST_F(TransformationTestsF, DecompositionRmsNorm_FusedByRMSFusion_WithGamma) {
+ const ov::Shape input_shape{1, 2, 6};
+ const std::vector<float> gamma_values{0.029f, 0.014f, 0.003f, 0.013f, 0.015f, 0.009f};
+ const float eps_value = 1e-5f;
+
+ {
+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, input_shape);
+ auto axes = ov::op::v0::Constant::create(ov::element::i64, ov::Shape{1}, {-1});
+ auto eps = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{}, {eps_value});
+ auto gamma = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{6}, gamma_values);
+
+ ov::pass::NodeRegistry reg;
+ auto rms = ov::decomposition::rms_norm(reg, input, axes, eps, gamma);
+
+ model = std::make_shared<ov::Model>(ov::OutputVector{rms}, ov::ParameterVector{input});
+ manager.register_pass<RMSFusion>(/*force_tail_convert=*/false);
+ }
+ {
+ auto input = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, input_shape);
+ auto gamma = ov::op::v0::Constant::create(ov::element::f32, ov::Shape{6}, gamma_values);
+ auto rms = std::make_shared<ov::op::internal::RMS>(input, gamma, eps_value, ov::element::f32);
+ model_ref = std::make_shared<ov::Model>(ov::OutputVector{rms}, ov::ParameterVector{input});
+ }
+
+ comparator.enable(FunctionsComparator::CmpValues::ACCURACY);
+ comparator.enable(FunctionsComparator::CmpValues::CONST_VALUES);
+ comparator.enable(FunctionsComparator::CmpValues::ATTRIBUTES);
+}
diff --git a/src/common/transformations/tests/decompositions/rope_decomposition_fuse_test.cpp b/src/common/transformations/tests/decompositions/rope_decomposition_fuse_test.cpp
new file mode 100644
index 00000000000..32377a9fd86
--- /dev/null
+++ b/src/common/transformations/tests/decompositions/rope_decomposition_fuse_test.cpp
@@ -0,0 +1,58 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+// Tests that verify reference decompositions stored in
+// `src/common/decompositions/` are always recognised and folded back into
+// their corresponding internal fused op by the matching transformation.
+
+#include <gtest/gtest.h>
+
+#include <memory>
+
+#include "common_test_utils/ov_test_utils.hpp"
+#include "openvino/core/model.hpp"
+#include "openvino/decompositions/rope.hpp"
+#include "openvino/op/parameter.hpp"
+#include "openvino/pass/manager.hpp"
+#include "ov_ops/rotary_positional_embeddings.hpp"
+#include "transformations/common_optimizations/fuse_rotary_positional_embeddings.hpp"
+
+using namespace testing;
+using namespace ov::pass;
+
+TEST_F(TransformationTestsF, DecompositionRope_FusedByRoPEFusion) {
+ disable_rt_info_check();
+
+ const size_t batch = 2;
+ const size_t num_heads = 4;
+ const size_t seq_length = 16;
+ const size_t head_size = 64;
+ const int64_t half_head_size = static_cast<int64_t>(head_size / 2);
+
+ const ov::Shape x_shape{batch, num_heads, seq_length, head_size};
+ const ov::Shape cos_sin_shape{batch, 1, seq_length, head_size / 2};
+
+ {
+ auto x = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, x_shape);
+ auto cos = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, cos_sin_shape);
+ auto sin = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, cos_sin_shape);
+
+ ov::pass::NodeRegistry reg;
+ auto rope = ov::decomposition::rope(reg, x, cos, sin, half_head_size);
+
+ model = std::make_shared<ov::Model>(ov::OutputVector{rope}, ov::ParameterVector{x, cos, sin});
+ manager.register_pass<RoPEFusion>();
+ }
+ {
+ auto x = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, x_shape);
+ auto cos = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, cos_sin_shape);
+ auto sin = std::make_shared<ov::op::v0::Parameter>(ov::element::f32, cos_sin_shape);
+
+ ov::op::internal::RoPE::Config config;
+ config.rotary_ndims = head_size;
+ config.cos_sin_ndims = head_size / 2;
+ auto rope = std::make_shared<ov::op::internal::RoPE>(ov::OutputVector{x, cos, sin}, config);
+
+ model_ref = std::make_shared<ov::Model>(ov::OutputVector{rope}, ov::ParameterVector{x, cos, sin});
+ }
+}
diff --git a/src/frontends/onnx/docs/supported_ops.md b/src/frontends/onnx/docs/supported_ops.md
index 1b9e71b8c76..e4a44f1bb89 100644
--- a/src/frontends/onnx/docs/supported_ops.md
+++ b/src/frontends/onnx/docs/supported_ops.md
@@ -134,6 +134,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)
| |QLinearConv |10 |10 | |
| |QLinearMatMul |10 |21, 10 | |
| |QuantizeLinear |21, 13, 10 |21, 19, 13, 10 | |
+| |RMSNormalization |23 |23 | |
| |RNN |1 |22, 14, 7, 1 | |
| |RandomNormal |1 |22, 1 | |
| |RandomNormalLike |1 |22, 1 | |
@@ -157,6 +158,7 @@ OpenVINO provides support for operations of Default Opset (empty in table below)
| |Resize |11, 10 |19, 18, 13, 11, 10 | |
| |ReverseSequence |10 |10 | |
| |RoiAlign |16, 10 |22, 16, 10 | |
+| |RotaryEmbedding |23 |23 | |
| |Round |11 |22, 11 | |
| |STFT |17 |17 | |
| |Scan |9, 8 |21, 19, 16, 11, 9, 8 | |
diff --git a/src/frontends/onnx/frontend/src/op/com.microsoft/rotary_embedding.cpp b/src/frontends/onnx/frontend/src/op/com.microsoft/rotary_embedding.cpp
index 15dda11eca7..da05c7e7f22 100644
--- a/src/frontends/onnx/frontend/src/op/com.microsoft/rotary_embedding.cpp
+++ b/src/frontends/onnx/frontend/src/op/com.microsoft/rotary_embedding.cpp
@@ -8,6 +8,7 @@
#include "exceptions.hpp"
#include "openvino/core/graph_util.hpp"
#include "openvino/core/rt_info.hpp"
+#include "openvino/decompositions/rope.hpp"
#include "openvino/frontend/exception.hpp"
#include "openvino/op/add.hpp"
#include "openvino/op/concat.hpp"
@@ -126,24 +127,9 @@ ov::OutputVector rotary_embedding(const ov::frontend::onnx::Node& node) {
rope_input = std::make_shared<v1::Reshape>(transposed_5d, input_4d_shape, false);
}
- // Core RoPE formula (matches RoPEFusionGPTOSS pattern for both modes)
- // first_ = first_half * cos - second_half * sin
- // second_ = second_half * cos + first_half * sin
- const auto split_axis = v0::Constant::create(ov::element::i64, ov::Shape{}, {-1});
- const auto split_lengths =
- v0::Constant::create(ov::element::i64, ov::Shape{2}, {half_head_size_val, half_head_size_val});
- // Split along last axis using constant split_lengths to enable RoPE fusion pattern matching
- auto in_split = std::make_shared<v1::VariadicSplit>(rope_input, split_axis, split_lengths)->outputs();
- auto first_half_mul_cos = std::make_shared<v1::Multiply>(in_split[0], cos_4d);
- auto second_half_mul_sin = std::make_shared<v1::Multiply>(in_split[1], sin_4d);
- const auto neg_one = v0::Constant::create(input.get_element_type(), ov::Shape{}, {-1.0f});
- auto neg_second_sin = std::make_shared<v1::Multiply>(second_half_mul_sin, neg_one);
- auto res_0 = std::make_shared<v1::Add>(first_half_mul_cos, neg_second_sin);
- auto second_half_mul_cos = std::make_shared<v1::Multiply>(in_split[1], cos_4d);
- auto first_half_mul_sin = std::make_shared<v1::Multiply>(in_split[0], sin_4d);
- auto res_1 = std::make_shared<v1::Add>(second_half_mul_cos, first_half_mul_sin);
- ov::Output<ov::Node> output =
- std::make_shared<v0::Concat>(ov::NodeVector{res_0, res_1}, -1); // [bs,num_heads,seqlen,head_size]
+ // Core RoPE formula via shared decomposition helper.
+ ov::pass::NodeRegistry rope_reg;
+ ov::Output<ov::Node> output = ov::decomposition::rope(rope_reg, rope_input, cos_4d, sin_4d, half_head_size_val);
// For interleaved mode, re-interleave the result
if (interleaved) {
diff --git a/src/frontends/onnx/frontend/src/op/rms_normalization.cpp b/src/frontends/onnx/frontend/src/op/rms_normalization.cpp
new file mode 100644
index 00000000000..c4f3e1ee642
--- /dev/null
+++ b/src/frontends/onnx/frontend/src/op/rms_normalization.cpp
@@ -0,0 +1,98 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "core/operator_set.hpp"
+#include "exceptions.hpp"
+#include "openvino/decompositions/rms_norm.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/convert.hpp"
+#include "openvino/op/convert_like.hpp"
+#include "openvino/op/multiply.hpp"
+#include "openvino/op/range.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/op/squeeze.hpp"
+#include "utils/common.hpp"
+
+using namespace ov::op;
+using ::ONNX_NAMESPACE::TensorProto_DataType;
+
+namespace ov {
+namespace frontend {
+namespace onnx {
+namespace ai_onnx {
+namespace opset_23 {
+
+ov::OutputVector rms_normalization(const ov::frontend::onnx::Node& node) {
+ // Operator definition: https://onnx.ai/onnx/operators/onnx__RMSNormalization.html
+ // Y = Mul(Cast(X / Sqrt(ReduceMean(X*X, [axis,..,rank-1]) + epsilon), T), scale)
+ // The inner inv-rms graph is built via the shared decomposition helper so that
+ // ov::pass::RMSFusion can fuse it back into ov::op::internal::RMS in plugins.
+ const auto inputs = node.get_ov_inputs();
+ CHECK_VALID_NODE(node,
+ inputs.size() == 2,
+ "RMSNormalization expects 2 input tensors (X, scale). Got: ",
+ inputs.size());
+
+ const int64_t axis = node.get_attribute_value<int64_t>("axis", -1);
+ const float epsilon = node.get_attribute_value<float>("epsilon", 1e-5f);
+ const int64_t stash_type_i =
+ node.get_attribute_value<int64_t>("stash_type",
+ static_cast<int64_t>(TensorProto_DataType::TensorProto_DataType_FLOAT));
+ const ov::element::Type stash_type = common::get_ov_element_type(stash_type_i);
+
+ ov::Output<ov::Node> x = inputs[0];
+ const ov::Output<ov::Node>& scale = inputs[1];
+ const ov::element::Type original_type = x.get_element_type();
+ const bool needs_cast = stash_type != original_type;
+
+ if (needs_cast) {
+ x = std::make_shared<v0::Convert>(x, stash_type);
+ }
+
+ // normalized_axes = [axis, axis+1, ..., rank(X)-1]
+ // For axis < 0, equivalent to Range(axis, 0, 1) which yields exactly the
+ // negative tail (e.g. axis=-2 → [-2, -1]).
+ const auto axes_start = v0::Constant::create(ov::element::i64, ov::Shape{}, {axis});
+ const auto axes_step = v0::Constant::create(ov::element::i64, ov::Shape{}, {1});
+ ov::Output<ov::Node> axes_end;
+ if (axis < 0) {
+ axes_end = v0::Constant::create(ov::element::i64, ov::Shape{}, {0});
+ } else {
+ // rank(x) = Squeeze(ShapeOf(ShapeOf(x)))
+ auto x_shape = std::make_shared<v3::ShapeOf>(x, ov::element::i64);
+ auto x_rank_1d = std::make_shared<v3::ShapeOf>(x_shape, ov::element::i64);
+ axes_end = std::make_shared<v0::Squeeze>(x_rank_1d);
+ }
+ auto axes = std::make_shared<v4::Range>(axes_start, axes_end, axes_step, ov::element::i64);
+
+ // Epsilon constant in the same precision as `x` (the helper's Add(ReduceMean, eps)
+ // requires matching dtypes; RMSFusion expects raw Constant, not ConvertLike).
+ const auto x_et = x.get_element_type();
+ ov::Output<ov::Node> eps;
+ if (x_et.is_static()) {
+ eps = v0::Constant::create(x_et, ov::Shape{}, {epsilon});
+ } else {
+ const auto eps_f32 = v0::Constant::create(ov::element::f32, ov::Shape{}, {epsilon});
+ eps = std::make_shared<v1::ConvertLike>(eps_f32, x);
+ }
+
+ // Build inv-rms via the shared helper (no scale here — scale is applied after the
+ // cast back to the original type, per ONNX spec).
+ ov::pass::NodeRegistry reg;
+ ov::Output<ov::Node> normalized = ov::decomposition::rms_norm(reg, x, axes, eps);
+
+ if (needs_cast) {
+ normalized = std::make_shared<v1::ConvertLike>(normalized, inputs[0]);
+ }
+
+ return {std::make_shared<v1::Multiply>(normalized, scale)};
+}
+
+ONNX_OP("RMSNormalization", OPSET_SINCE(1), ai_onnx::opset_23::rms_normalization);
+
+} // namespace opset_23
+} // namespace ai_onnx
+} // namespace onnx
+} // namespace frontend
+} // namespace ov
diff --git a/src/frontends/onnx/frontend/src/op/rotary_embedding.cpp b/src/frontends/onnx/frontend/src/op/rotary_embedding.cpp
new file mode 100644
index 00000000000..60405025871
--- /dev/null
+++ b/src/frontends/onnx/frontend/src/op/rotary_embedding.cpp
@@ -0,0 +1,230 @@
+// Copyright (C) 2018-2026 Intel Corporation
+// SPDX-License-Identifier: Apache-2.0
+//
+
+#include "core/null_node.hpp"
+#include "core/operator_set.hpp"
+#include "exceptions.hpp"
+#include "openvino/decompositions/rope.hpp"
+#include "openvino/op/concat.hpp"
+#include "openvino/op/constant.hpp"
+#include "openvino/op/gather.hpp"
+#include "openvino/op/reshape.hpp"
+#include "openvino/op/shape_of.hpp"
+#include "openvino/op/slice.hpp"
+#include "openvino/op/transpose.hpp"
+#include "openvino/op/unsqueeze.hpp"
+#include "openvino/op/variadic_split.hpp"
+#include "utils/common.hpp"
+
+using namespace ov::op;
+
+namespace ov {
+namespace frontend {
+namespace onnx {
+namespace ai_onnx {
+namespace opset_23 {
+
+namespace {
+
+// Build a 1-D i64 Constant from a list of values. We use std::vector explicitly so
+// that mixed `int64_t` / `int` literals don't break Constant::create template deduction.
+std::shared_ptr<v0::Constant> i64_const(const std::vector<int64_t>& values) {
+ return v0::Constant::create(ov::element::i64, ov::Shape{values.size()}, values);
+}
+
+// Reshape with `special_zero=true` so a literal 0 in `target` means "keep the
+// corresponding input dimension" — saves us from gathering shape parts dynamically.
+std::shared_ptr<ov::Node> reshape_keep(const ov::Output<ov::Node>& x, const std::vector<int64_t>& target) {
+ return std::make_shared<v1::Reshape>(x, i64_const(target), /*special_zero=*/true);
+}
+
+} // namespace
+
+ov::OutputVector rotary_embedding(const ov::frontend::onnx::Node& node) {
+ // Operator definition: https://onnx.ai/onnx/operators/onnx__RotaryEmbedding.html
+ //
+ // Strategy: normalize layout to [bs, num_heads, seq, head_size], optionally peel off
+ // the no-rotate tail of the head dim, optionally de-interleave for the interleaved
+ // mode, delegate the core formula to ov::decomposition::rope (recognised by
+ // ov::pass::RoPEFusion), then undo the wrappers.
+ //
+ // Note: we never need to know `head_size` statically — the rope helper's split is
+ // sized from `half_rotary_dim` (derived from `rotary_embedding_dim` or cos_cache),
+ // and partial-rotation tail length uses VariadicSplit's `-1` (take-the-rest) form.
+ const auto inputs = node.get_ov_inputs();
+ CHECK_VALID_NODE(node,
+ inputs.size() == 3 || inputs.size() == 4,
+ "RotaryEmbedding expects 3 or 4 inputs (X, cos_cache, sin_cache, [position_ids]). Got: ",
+ inputs.size());
+
+ const auto& input = inputs[0];
+ const auto& cos_cache = inputs[1];
+ const auto& sin_cache = inputs[2];
+ const bool has_position_ids = inputs.size() == 4 && !ov::op::util::is_null(inputs[3]);
+
+ const int64_t interleaved = node.get_attribute_value<int64_t>("interleaved", 0);
+ const int64_t rotary_dim = node.get_attribute_value<int64_t>("rotary_embedding_dim", 0);
+ const int64_t num_heads = node.get_attribute_value<int64_t>("num_heads", 0);
+ const bool partial = rotary_dim > 0;
+ if (partial) {
+ CHECK_VALID_NODE(node, rotary_dim % 2 == 0, "rotary_embedding_dim must be even, got: ", rotary_dim);
+ }
+
+ // The shared rope helper requires a static `half_rotary_dim` to build a VariadicSplit.
+ const auto& cos_pshape = cos_cache.get_partial_shape();
+ CHECK_VALID_NODE(node,
+ cos_pshape.rank().is_static() && cos_pshape.rank().get_length() >= 2 &&
+ cos_pshape[cos_pshape.rank().get_length() - 1].is_static(),
+ "cos_cache must have static rank >= 2 and a static last dimension, got: ",
+ cos_pshape);
+ const int64_t cos_last_dim = cos_pshape[cos_pshape.rank().get_length() - 1].get_length();
+ const int64_t half_rotary_dim = partial ? rotary_dim / 2 : cos_last_dim;
+
+ // The cos/sin cache must be wide enough to feed half_rotary_dim columns into
+ // the rope helper; otherwise the downstream Slice/VariadicSplit would build
+ // an invalid graph that only fails much later at shape inference.
+ CHECK_VALID_NODE(node,
+ half_rotary_dim <= cos_last_dim,
+ "cos_cache last dimension (",
+ cos_last_dim,
+ ") must be >= rotary_embedding_dim/2 (",
+ half_rotary_dim,
+ ").");
+
+ const auto& input_pshape = input.get_partial_shape();
+ const auto input_rank = input_pshape.rank();
+ CHECK_VALID_NODE(node,
+ input_rank.is_static() && (input_rank.get_length() == 3 || input_rank.get_length() == 4),
+ "RotaryEmbedding input must have static rank 3 or 4.");
+ const bool input_is_3d = input_rank.get_length() == 3;
+ if (input_is_3d) {
+ CHECK_VALID_NODE(node, num_heads > 0, "num_heads attribute is required for 3D input.");
+ }
+
+ // When the head dimension is statically known, validate that rotary_dim fits
+ // into it. For 4D input that is the last dim directly; for 3D input the head
+ // dim is hidden/num_heads, where hidden is the last input dim.
+ if (partial) {
+ const auto& last_input_dim = input_pshape[input_rank.get_length() - 1];
+ if (last_input_dim.is_static()) {
+ const int64_t last_input_dim_val = last_input_dim.get_length();
+ if (input_is_3d) {
+ CHECK_VALID_NODE(node,
+ last_input_dim_val % num_heads == 0,
+ "Hidden size (",
+ last_input_dim_val,
+ ") must be divisible by num_heads (",
+ num_heads,
+ ").");
+ const int64_t head_size = last_input_dim_val / num_heads;
+ CHECK_VALID_NODE(node,
+ rotary_dim <= head_size,
+ "rotary_embedding_dim (",
+ rotary_dim,
+ ") must be <= head_size (",
+ head_size,
+ ").");
+ } else {
+ CHECK_VALID_NODE(node,
+ rotary_dim <= last_input_dim_val,
+ "rotary_embedding_dim (",
+ rotary_dim,
+ ") must be <= head_size (",
+ last_input_dim_val,
+ ").");
+ }
+ }
+ }
+
+ // ---- Step 1. Normalize layout to [bs, num_heads, seq, head_size] ----
+ const auto perm_bnsh = i64_const({0, 2, 1, 3});
+ const auto input_shape = input_is_3d ? std::make_shared<v3::ShapeOf>(input, ov::element::i64) : nullptr;
+
+ ov::Output<ov::Node> x = input;
+ if (input_is_3d) {
+ // [bs, seq, hidden] -> [bs, seq, num_heads, head_size] -> [bs, num_heads, seq, head_size]
+ x = reshape_keep(input, {0, 0, num_heads, -1});
+ x = std::make_shared<v1::Transpose>(x, perm_bnsh);
+ }
+
+ // ---- Step 2. For partial rotation, peel off the no-rotate tail of the head dim ----
+ ov::Output<ov::Node> x_rotate = x;
+ ov::Output<ov::Node> x_no_rotate;
+ if (partial) {
+ const auto axis_neg1_scalar = v0::Constant::create(ov::element::i64, ov::Shape{}, {int64_t{-1}});
+ // {rotary_dim, -1}: -1 = "the rest". When rotary_dim == head_size, the second piece is empty.
+ const auto lengths = i64_const({rotary_dim, -1});
+ auto split = std::make_shared<v1::VariadicSplit>(x, axis_neg1_scalar, lengths);
+ x_rotate = split->output(0);
+ x_no_rotate = split->output(1);
+ }
+
+ // ---- Step 3. Build cos/sin in shape [..., 1, ..., half_rotary_dim] ----
+ ov::Output<ov::Node> cos = cos_cache;
+ ov::Output<ov::Node> sin = sin_cache;
+ if (has_position_ids) {
+ const auto axis0 = v0::Constant::create(ov::element::i64, ov::Shape{}, {int64_t{0}});
+ cos = std::make_shared<v8::Gather>(cos_cache, inputs[3], axis0);
+ sin = std::make_shared<v8::Gather>(sin_cache, inputs[3], axis0);
+ }
+ // For partial rotation, the cache may hold the full head_size/2; slice it down.
+ if (cos_last_dim > half_rotary_dim) {
+ cos = std::make_shared<v8::Slice>(cos,
+ i64_const({0}),
+ i64_const({half_rotary_dim}),
+ i64_const({1}),
+ i64_const({-1}));
+ sin = std::make_shared<v8::Slice>(sin,
+ i64_const({0}),
+ i64_const({half_rotary_dim}),
+ i64_const({1}),
+ i64_const({-1}));
+ }
+ // Insert axis=1 broadcast dim → [bs, 1, seq, half_rotary_dim].
+ const auto axis_1_1d = i64_const({1});
+ cos = std::make_shared<v0::Unsqueeze>(cos, axis_1_1d);
+ sin = std::make_shared<v0::Unsqueeze>(sin, axis_1_1d);
+
+ // ---- Step 4. Optionally de-interleave so the split-half formula in `rope` applies ----
+ // [.., rotary_dim] -reshape-> [.., half, 2] -transpose [0,1,2,4,3]-> [.., 2, half] -reshape-> [.., rotary_dim]
+ const auto perm_5d = i64_const({0, 1, 2, 4, 3});
+ ov::Output<ov::Node> rope_input = x_rotate;
+ if (interleaved) {
+ rope_input = reshape_keep(x_rotate, {0, 0, 0, half_rotary_dim, 2});
+ rope_input = std::make_shared<v1::Transpose>(rope_input, perm_5d);
+ rope_input = reshape_keep(rope_input, {0, 0, 0, -1});
+ }
+
+ // ---- Step 5. Core RoPE formula via the shared decomposition helper ----
+ ov::pass::NodeRegistry rope_reg;
+ ov::Output<ov::Node> rotated = ov::decomposition::rope(rope_reg, rope_input, cos, sin, half_rotary_dim);
+
+ // ---- Step 6. Re-interleave if needed (mirror of step 4) ----
+ if (interleaved) {
+ rotated = reshape_keep(rotated, {0, 0, 0, 2, half_rotary_dim});
+ rotated = std::make_shared<v1::Transpose>(rotated, perm_5d);
+ rotated = reshape_keep(rotated, {0, 0, 0, -1});
+ }
+
+ // ---- Step 7. Concat rotated and no-rotate parts back along the head dim ----
+ ov::Output<ov::Node> output =
+ partial ? std::make_shared<v0::Concat>(ov::OutputVector{rotated, x_no_rotate}, -1) : rotated;
+
+ // ---- Step 8. Restore original 3D layout if needed ----
+ if (input_is_3d) {
+ // [bs, num_heads, seq, head_size] -> [bs, seq, num_heads, head_size] -> [bs, seq, hidden]
+ output = std::make_shared<v1::Transpose>(output, perm_bnsh);
+ output = std::make_shared<v1::Reshape>(output, input_shape, /*special_zero=*/false);
+ }
+
+ return {output};
+}
+
+ONNX_OP("RotaryEmbedding", OPSET_SINCE(1), ai_onnx::opset_23::rotary_embedding);
+
+} // namespace opset_23
+} // namespace ai_onnx
+} // namespace onnx
+} // namespace frontend
+} // namespace ov
diff --git a/src/frontends/onnx/tests/__init__.py b/src/frontends/onnx/tests/__init__.py
index 6732e2c9114..1b7ccd8403b 100644
--- a/src/frontends/onnx/tests/__init__.py
+++ b/src/frontends/onnx/tests/__init__.py
@@ -177,7 +177,5 @@ skip_issue_119896 = pytest.mark.skip(reason="Unsupported element type: FLOAT8")
# ONNX 1.18
xfail_issue_171767 = pytest.mark.skip(reason="Unsupported element type: FLOAT4E2M1")
-xfail_issue_171768 = pytest.mark.skip(reason="Unsupported feature: RMSNormalization")
-xfail_issue_171770 = pytest.mark.skip(reason="Unsupported feature: RotaryEmbedding")
xfail_issue_171771 = pytest.mark.skip(reason="Mismatches in tests: Top K values")
xfail_issue_171772 = pytest.mark.skip(reason="Mismatches in tests: AveragePool")
diff --git a/src/frontends/onnx/tests/models/rms_normalization.prototxt b/src/frontends/onnx/tests/models/rms_normalization.prototxt
new file mode 100644
index 00000000000..1168f858842
--- /dev/null
+++ b/src/frontends/onnx/tests/models/rms_normalization.prototxt
@@ -0,0 +1,63 @@
+ir_version: 11
+producer_name: "OpenVINO ONNX Frontend"
+graph {
+ node {
+ input: "X"
+ input: "scale"
+ output: "Y"
+ op_type: "RMSNormalization"
+ attribute {
+ name: "axis"
+ i: -1
+ type: INT
+ }
+ attribute {
+ name: "epsilon"
+ f: 1e-05
+ type: FLOAT
+ }
+ }
+ name: "rms_norm_graph"
+ initializer {
+ dims: 4
+ data_type: 1
+ name: "scale"
+ raw_data: "\000\000\200?\000\000\200?\000\000\200?\000\000\200?"
+ }
+ input {
+ name: "X"
+ type {
+ tensor_type {
+ elem_type: 1
+ shape {
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 4
+ }
+ }
+ }
+ }
+ }
+ output {
+ name: "Y"
+ type {
+ tensor_type {
+ elem_type: 1
+ shape {
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 4
+ }
+ }
+ }
+ }
+ }
+}
+opset_import {
+ domain: ""
+ version: 23
+}
diff --git a/src/frontends/onnx/tests/models/rotary_embedding.prototxt b/src/frontends/onnx/tests/models/rotary_embedding.prototxt
new file mode 100644
index 00000000000..8d553a94444
--- /dev/null
+++ b/src/frontends/onnx/tests/models/rotary_embedding.prototxt
@@ -0,0 +1,81 @@
+ir_version: 11
+producer_name: "OpenVINO ONNX Frontend"
+graph {
+ node {
+ input: "X"
+ input: "cos_cache"
+ input: "sin_cache"
+ output: "Y"
+ op_type: "RotaryEmbedding"
+ attribute {
+ name: "interleaved"
+ i: 0
+ type: INT
+ }
+ }
+ name: "rotary_embedding_graph"
+ initializer {
+ dims: 1
+ dims: 2
+ dims: 2
+ data_type: 1
+ name: "cos_cache"
+ raw_data: "\000\000\200?\000\000\200?\000\000\200?\000\000\200?"
+ }
+ initializer {
+ dims: 1
+ dims: 2
+ dims: 2
+ data_type: 1
+ name: "sin_cache"
+ raw_data: "\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000\000"
+ }
+ input {
+ name: "X"
+ type {
+ tensor_type {
+ elem_type: 1
+ shape {
+ dim {
+ dim_value: 1
+ }
+ dim {
+ dim_value: 1
+ }
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 4
+ }
+ }
+ }
+ }
+ }
+ output {
+ name: "Y"
+ type {
+ tensor_type {
+ elem_type: 1
+ shape {
+ dim {
+ dim_value: 1
+ }
+ dim {
+ dim_value: 1
+ }
+ dim {
+ dim_value: 2
+ }
+ dim {
+ dim_value: 4
+ }
+ }
+ }
+ }
+ }
+}
+opset_import {
+ domain: ""
+ version: 23
+}
diff --git a/src/frontends/onnx/tests/onnx_import.in.cpp b/src/frontends/onnx/tests/onnx_import.in.cpp
index 8a512bf7a1e..f199de6169e 100644
--- a/src/frontends/onnx/tests/onnx_import.in.cpp
+++ b/src/frontends/onnx/tests/onnx_import.in.cpp
@@ -7668,6 +7668,39 @@ OPENVINO_TEST(${BACKEND_NAME}, onnx_layer_normalization_biased) {
test_case.run_with_tolerance_as_fp(0.0001f);
}
+// Minimal smoke test for the standard ONNX opset-23 RMSNormalization translator.
+// Verifies that the decomposition built via ov::decomposition::rms_norm produces
+// the expected RMS-normalized output. Comprehensive coverage lives in the ONNX
+// node conformance suite (test_rms_normalization_*).
+OPENVINO_TEST(${BACKEND_NAME}, onnx_rms_normalization) {
+ const auto model = convert_model("rms_normalization.onnx");
+ auto test_case = test::TestCase(model, s_device);
+
+ test_case.add_input<float>(Shape{2, 4}, {1.0f, 2.0f, 3.0f, 4.0f, 1.0f, 1.0f, 1.0f, 1.0f});
+ // RMS over last axis: sqrt(mean(x^2) + 1e-5)
+ // Row 0: sqrt(7.5 + 1e-5) ~ 2.738614
+ // Row 1: sqrt(1.0 + 1e-5) ~ 1.0000050
+ test_case.add_expected_output<float>(
+ Shape{2, 4},
+ {0.36514688f, 0.73029375f, 1.09544063f, 1.46058750f, 0.99999499f, 0.99999499f, 0.99999499f, 0.99999499f});
+ test_case.run_with_tolerance_as_fp(1e-4f);
+}
+
+// Minimal smoke test for the standard ONNX opset-23 RotaryEmbedding translator.
+// Uses cos=1, sin=0 so the rotation is identity — the test verifies that the
+// reshape/transpose/decomposition pipeline plumbs the input through unchanged.
+// Comprehensive correctness coverage lives in the ONNX node conformance suite
+// (test_rotary_embedding_*).
+OPENVINO_TEST(${BACKEND_NAME}, onnx_rotary_embedding_identity) {
+ const auto model = convert_model("rotary_embedding.onnx");
+ auto test_case = test::TestCase(model, s_device);
+
+ const std::vector<float> input = {0.1f, 0.2f, 0.3f, 0.4f, 0.5f, 0.6f, 0.7f, 0.8f};
+ test_case.add_input<float>(Shape{1, 1, 2, 4}, input);
+ test_case.add_expected_output<float>(Shape{1, 1, 2, 4}, input);
+ test_case.run_with_tolerance_as_fp(1e-5f);
+}
+
OPENVINO_TEST(${BACKEND_NAME}, onnx_model_attention_mha_4d) {
auto model = convert_model("attention_mha_4d.onnx");
auto test_case = test::TestCase(model, s_device);
diff --git a/src/frontends/onnx/tests/tests_python/test_backend.py b/src/frontends/onnx/tests/tests_python/test_backend.py
index d0554ce1e06..55e747620ef 100644
--- a/src/frontends/onnx/tests/tests_python/test_backend.py
+++ b/src/frontends/onnx/tests/tests_python/test_backend.py
@@ -72,8 +72,6 @@ from tests import (
xfail_issue_139937,
xfail_issue_139938,
xfail_issue_171767,
- xfail_issue_171768,
- xfail_issue_171770,
xfail_issue_171771,
xfail_issue_171772,
)
@@ -629,39 +627,6 @@ tests_expected_to_fail = [
"OnnxBackendNodeModelTest.test_dequantizelinear_float4e2m1_cpu",
"OnnxBackendNodeModelTest.test_quantizelinear_float4e2m1_cpu",
),
- (
- xfail_issue_171768,
- "OnnxBackendNodeModelTest.test_rms_normalization_2d_axis0_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_2d_axis1_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_2d_axis_negative_1_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_2d_axis_negative_2_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_3d_axis0_epsilon_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_3d_axis1_epsilon_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_3d_axis2_epsilon_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_3d_axis_negative_1_epsilon_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_3d_axis_negative_2_epsilon_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_3d_axis_negative_3_epsilon_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis0_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis1_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis2_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis3_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis_negative_1_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis_negative_2_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis_negative_3_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_4d_axis_negative_4_cpu",
- "OnnxBackendNodeModelTest.test_rms_normalization_default_axis_cpu",
- ),
- (
- xfail_issue_171770,
- "OnnxBackendNodeModelTest.test_rotary_embedding_3d_input_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_interleaved_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_no_position_ids_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_no_position_ids_interleaved_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_no_position_ids_rotary_dim_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_with_interleaved_rotary_dim_cpu",
- "OnnxBackendNodeModelTest.test_rotary_embedding_with_rotary_dim_cpu",
- ),
(
xfail_issue_171771,
"OnnxBackendNodeModelTest.test_top_k_same_values_2d_cpu",
diff --git a/src/frontends/pytorch/src/op/norm.cpp b/src/frontends/pytorch/src/op/norm.cpp
index 28bbfddf06b..a019e53697b 100644
--- a/src/frontends/pytorch/src/op/norm.cpp
+++ b/src/frontends/pytorch/src/op/norm.cpp
@@ -2,6 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//
+#include "openvino/decompositions/rms_norm.hpp"
#include "openvino/frontend/pytorch/node_context.hpp"
#include "openvino/op/abs.hpp"
#include "openvino/op/add.hpp"
@@ -369,21 +370,14 @@ OutputVector translate_rms_norm(const NodeContext& context) {
auto axes_range = context.mark_node(std::make_shared<v4::Range>(num_axes, zero, minus_one, element::i32));
auto axes = context.mark_node(std::make_shared<v1::Multiply>(axes_range, minus_one));
- // decomposition of RMSNorm to be fused by plugins
- auto power_const = context.mark_node(v0::Constant::create(ov::element::f32, {}, {2.f}));
- power_const = context.mark_node(std::make_shared<v1::ConvertLike>(power_const, x));
- auto power = context.mark_node(std::make_shared<v1::Power>(x, power_const));
- auto mean = context.mark_node(std::make_shared<v1::ReduceMean>(power, axes, true));
- auto add_eps = context.mark_node(std::make_shared<v1::Add>(mean, eps));
- auto sqrt = context.mark_node(std::make_shared<v0::Sqrt>(add_eps));
- auto div_const = context.mark_node(v0::Constant::create(ov::element::f32, {}, {-1}));
- div_const = context.mark_node(std::make_shared<v1::ConvertLike>(div_const, x));
- auto div = context.mark_node(std::make_shared<v1::Power>(sqrt, div_const));
- auto result = context.mark_node(std::make_shared<v1::Multiply>(x, div));
-
+ // Build the RMSNorm decomposition via the shared helper.
+ ov::Output<ov::Node> scale;
if (!context.input_is_none(2)) {
- result = context.mark_node(std::make_shared<v1::Multiply>(context.get_input(2), result));
+ scale = context.get_input(2);
}
+ ov::pass::NodeRegistry reg;
+ auto result = ov::decomposition::rms_norm(reg, x, axes, eps, scale);
+ context.mark_nodes(reg.get());
return {result};
}