One little side note to my reply above is that torch.rfft (and torch.fft) returns a complex-valued tensor. In other words, the dimension of the output tensor will be greater than the input, and the last axis/dimension contains both the real and complex coefficients.