Folding 2D-tensor back to 1D

I have a 1D signal, which I subject to the following operations:

  1. Split into overlapping frames. I can do that with torch.Tensor.unfold function.
  2. Work with each frame individually.
  3. Combine the result back into 1D. The originally overlapping regions need to be summed up.

How can i perform the 3rd step efficiently? There is a class torch.nn.Fold, but it only works for image-like tensors with a channel dimension.


I don’t think we support this indeed. You can maybe create dummy dimensions of size 1. To make it into a image-like Tensor?