Function canonicalize_dim
pub fn canonicalize_dim<Dim>(idx: Dim, rank: usize, wrap_scalar: bool) -> usizewhere
Dim: AsIndex,
Expand description
Canonicalizes and bounds checks a dimension index with negative indexing support.
§Arguments
idx
- The dimension index to canonicalize.rank
- The number of dimensions.wrap_scalar
- If true, pretend scalars have rank=1.
§Returns
The canonicalized dimension index.
§Panics
- If
wrap_scalar
is false and the tensor has no dimensions. - If the dimension index is out of range.