Closed skeydan closed 1 year ago
This indeed looks like a bug in torch. Looks like we don't correctly handle the case where two tensors are passed in the indexes. It seems that what happens in PyTorch is that we don't correctly treat the tensors as coordinates that we want to extract.
Actually, I just found a note here
Note: Starting from version 0.5.0, vector indexing in torch follows R semantics, prior to that the behavior was similar to numpy’s advanced indexing. To use the old behavior, consider using ?torch_index, ?torch_index_put or torch_indexput.
Maybe this works?
torch_index(delay_bufs[1,], list(channel_idxs + 1L, third+1L))
Actually, I just found a note here
it's "read the docs", right? :-)) Thanks so much, that works (with adaptations for the situation)!
All tests passing now :-)
I would normally try to not do it, but I'll be adding commits due to
https://github.com/curso-r/torchaudio/issues/46
here as well, since some of them depend on this branch.
OK, done :-) I guess this would be ready for a release, then? (See also https://github.com/curso-r/torchaudio/issues/46)
This fixes all tests but one: https://github.com/curso-r/torchaudio/actions/runs/3827989720/jobs/6513085424#step:8:159
As to the remaining one, I suspect this could be an issue with indexing in torch. Comparing, 1:1, the R and Python versions of
flanger
, I see the first difference appearing here:https://github.com/pytorch/audio/blob/d0dca11546567bc96886e9965224e4e6681170ba/torchaudio/functional/filtering.py#L838
https://github.com/curso-r/torchaudio/blob/3667cc044e0fcd8ae7b68a7a9343ee1537ea686d/R/functional.R#L1540
Extracting the relevant code, we have this:
Python:
R:
@dfalbel what do you think? With [advanced] indexing, due to my "spatial handicap", I really have awful problems ...