Unfold and fold to apply the overlap and add algorithm

Hi, I have an audio processing problem, first I need to chunk and put through and rnn, i start with a tensor of shape
(64, 16308) then I apply fold:

tensor.fold(-1, 178, 89)

so I get the tensor with shape (64, 182, 178) with nice overlapping sections

now I can pass it through my rnns. Problem is, now I would like to apply the overlap and add method to get the original tensor back, I thought nn.Fold would be a good match to try and do that, but I dont understand its use well enough to know if I can even use it to do that.

I assume you were using tensor.unfold to create the patches.
If that’s the case, nn.Fold should be working as it’s the reverting operation to nn.Unfold.
Where are you currently stuck and what have you tried so far?

Last night, after a lot of try and error I got nn.Unfold to work, what I had to do was now that I had a tensor with shape (64,182, 178) I transposed it to (64, 178, 182) and now i can use nn.Fold(my_tensor, output_size=(1 ,16198), kernel_size=(1, 178) stride=(1, 89)) to get back a tensor with the original size of (1, 16198) with the overlapping sections added, completing the overlap and add algirithm, sorry that i said my original tensor was shaped (1, 16308) when it is actually (1, 16198). Still not very sure of how nn.Fold works though.