Skip to main content

ClikaRT::ops::norm

function

norm()

Tensor norm(
    Tensor x,
    Scalar p = 2.0,
    ClikaRT::Span<const std::int64_t> dims = {},
    bool keepdim = false
)

The p-norm of x over dims.

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

Empty dims reduces every dimension.

Parameters

  • x: the input tensor; float dtype.
  • p: the norm degree, an int or float Scalar, 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 = x minus dims.

Throws

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

Declared in ClikaRT/compute/ops.h, line 4339