meddlr.ops.complex.channels_first#

meddlr.ops.complex.channels_first(x: Tensor)[source]#

Permute complex-valued x to channels-first convention.

For complex values, there are two potential conventions:

  1. x is complex-valued: (B,...,C) -> (B, C, ...).

  2. The real and imaginary components are stored in the last dimension. (B,...,C,2) -> (B, C, ..., 2).

Parameters

x (torch.Tensor) – A complex-valued tensor of shape (B,...,C) or a real-valued tensor of shape (B,...,C,2).

Returns

A channels-first tensor. If x is complex,

this will also be complex. If x is the real-view of a complex tensor, this will also be the real view.

Return type

torch.Tensor