---
title: "ClikaRT::ops::norm"
sidebar_label: "norm"
description: "The p-norm of input over dims. \\[ \\lVert x \\rVert_p = \\Bigl(\\sum_{i \\in \\text{dims}} |x_i|^p \\Bigr)^{1/p} \\] Empty dims reduces every dimension. input the input tensor; float dtype."
---

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

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

## norm() {#norm}

<div class="api-signature">

[`Tensor`](../Tensor.md) **`norm`**(<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Tensor`](../Tensor.md) `input`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`Scalar`](../Scalar.md) `p` `=` `2.0`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;[`ClikaRT::Span`](../Span.md)`<const std::int64_t>` `dims` `=` `{}`,<br />
&nbsp;&nbsp;&nbsp;&nbsp;`bool` `keepdim` `=` `false`<br />
)

</div>

The `p`-norm of `input` over `dims`.

$$
\lVert x \rVert_p = \Bigl(\sum_{i \in \text{dims}} |x_i|^p
    \Bigr)^{1/p}
$$

Empty `dims` reduces every dimension.

**Parameters**

- `input`: the input tensor; float dtype.
- `p`: the norm degree, an int or float [`Scalar`](../Scalar.md), kind-preserved; default 2 (Euclidean).
- `dims`: axes to reduce; empty = all axes.
- `keepdim`: keep reduced axes as size-1 dims; default false.

**Returns:** the norm values; shape = `input` minus `dims`.

**Throws**

- `ClikaRT::Error`: (`INVALID_ARGUMENT`) on an out-of-range `dims` entry.

<div class="api-declared">

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

</div>
