---
title: "ClikaRT::ops::rms_norm"
sidebar_label: "rms_norm"
description: "Root-mean-square normalization over the trailing normalized_shape dims (no mean subtraction)."
---

<!-- Generated by tools/doxygen2mdx from Doxygen XML. Do not edit. -->

<span class="api-kind api-kind--function">function</span>

## rms\_norm() {#rms_norm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`rms_norm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `normalized_shape`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `weight` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`OptionalTensor`](../../index.md#OptionalTensor) `bias` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<double>` `eps` `=` `std::nullopt`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<`[`Activation`](./index.md#Activation)`>` `activation` `=` `std::nullopt`<br />
)

</div>

Root-mean-square normalization over the trailing `normalized_shape` dims (no mean subtraction).

$$
\mathrm{out} = \frac{x}{\sqrt{\mathrm{E}[x^2] + \varepsilon}}
    \cdot \gamma + \beta
$$

The transformer-style norm: statistics are the mean SQUARE only, per position over the trailing dims. Optional fused `activation` applies to the post-affine value (gated kinds are not accepted).

**Parameters**

- `input`: the input tensor; float dtype.
- `normalized_shape`: the trailing dims that form one group.
- `weight`: optional gain (gamma), shaped `normalized_shape`.
- `bias`: optional post-norm shift, shaped `normalized_shape`.
- `eps`: stability floor; `std::nullopt` selects 1e-6.
- `activation`: optional fused activation; absent = none.

**Returns:** a new tensor, same shape and dtype as `input`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when the trailing dims do not match `normalized_shape` or an affine operand is mis-shaped.

<div class="api-declared">

Declared in `ClikaRT/compute/ops.h`, line 3825

</div>
