mrpro.utils.reshape_broadcasted

mrpro.utils.reshape_broadcasted(tensor: Tensor, *shape: int) Tensor[source]

Reshape a tensor while preserving broadcasted (stride 0) dimensions where possible.

Parameters:
  • tensor (Tensor) – The input tensor to reshape.

  • shape (int) – The target shape for the tensor. One of the values can be -1 and its size will be inferred.

Returns:

A tensor reshaped to the target shape, preserving broadcasted dimensions where feasible.