orient_and_conform#

hypercoil.engine.axisutil.orient_and_conform(input: Tensor, axis: int | Sequence[int], reference: Tensor | None = None, dim: int | None = None) Tensor[source]#

Orient an input tensor along a set of axes, and conform its overall dimension to equal that of a reference.

Warning

If both reference and dim are provided, then dim takes precedence.

Parameters:
inputtensor

Input tensor.

axistuple

Output axes along which the tensor’s input dimensions should be reoriented. This should be an n-tuple, where n is the number of axes in the input tensor. These axes must be in the same order in the input tensor; if they are not, the input must be transposed before being oriented.

referencetensor or None

Reference tensor. The output is unsqueezed so that its total dimension equals that of the reference. Either a reference or an explicit output dimension (dim) must be provided.

dimint or None

Number of tensor axes in the desired output.

Returns:
tensor

Reoriented tensor with singleton axes appended to conform with the reference number of axes.