---
title: "ClikaRT::ops::renorm"
sidebar_label: "renorm"
description: "Caps each sub-tensor's p-norm along dim at maxnorm. Every slice along dim whose p-norm exceeds maxnorm is rescaled to exactly maxnorm; slices already within the bound pass through unchanged."
---

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

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

## renorm() {#renorm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`renorm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Scalar`](../Scalar.md) `p`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`int64_t` `dim`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Scalar`](../Scalar.md) `maxnorm`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`std::optional<double>` `eps` `=` `std::nullopt`<br />
)

</div>

Caps each sub-tensor's `p`-norm along `dim` at `maxnorm`.

Every slice along `dim` whose `p`-norm exceeds `maxnorm` is rescaled to exactly `maxnorm`; slices already within the bound pass through unchanged.

**Parameters**

- `input`: the input tensor; float dtype.
- `p`: the norm degree, an int or float [`Scalar`](../Scalar.md), kind-preserved.
- `dim`: the axis whose slices are re-normalized.
- `maxnorm`: the norm ceiling: int or float [`Scalar`](../Scalar.md).
- `eps`: divide-by-zero floor; `std::nullopt` selects 1e-7.

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

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) when `dim` is out of range.

<div class="api-declared">

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

</div>
