Fix batched iSTFT #2
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The former iSTFT code has a bug which will produce wrong results when batch_size > 1:
When you use
torch.where(condition), you get a tuple containing 3 tensors representing the indices on dimension 0, 1, 2, respectively. However,coffidxis of shape[1, 1, T]whileoutputsis of shape[B, 1, T]. Thus, you will only get 0 on the first dim ofcoffand the later calculation only happens onoutputs[0, ...]. The rest part (output[1:, ...]) is never updated.The fix is either using
torch.repeatto make coff[B, 1, T]too, or usingtorch.where(condition, a, b)to get a combinedcoffbased on the condition. This PR applies the latter solution.