Skip to main content

ClikaRT::ops::renorm

function

renorm()

Tensor renorm(
    Tensor x,
    Scalar p,
    int64_t dim,
    Scalar maxnorm,
    std::optional<double> eps = std::nullopt
)

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

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

Returns: a new tensor, same shape and dtype as x.

Throws

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

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