fn
normalize_axes
→std::vector<int>int normalize_axes(const int & axes, int ndim, const char * op)Canonicalise a list of axis indices for an ndim-rank tensor.
Checks the list through distinct_dims, then sorts it ascending.
When axes is empty the function treats the call as "reduce over
everything" and returns [0, ndim). A 0-d tensor has no axis to
reduce, so any accepted axis list comes back empty.
Parameters
axesconst std::vector<int>&Raw axis list; may contain negatives.
ndimintRank of the tensor the axes refer to.
opconst char*Op name the errors carry.
Returns
std::vector<int>Sorted, all-positive axis list.
Raises
IndexErrorSome entry of
axes is refused by wrap_dim.LucidErrorTwo entries name the same axis.