mrpro.utils.reduce_view

mrpro.utils.reduce_view(x: Tensor, dim: int | Sequence[int] | None = None) Tensor[source]

Reduce expanded dimensions in a view to singletons.

Reduce either all or specific dimensions to a singleton if it points to the same memory address. This undoes expand.

Parameters:
  • x – input tensor

  • dim – only reduce expanded dimensions in the specified dimensions. If None, reduce all expanded dimensions.