FluxML/Torch.jl

How to implement the `torch.gather` function?

findmyway opened this issue · 1 comments

With Array in Julia, I can use m[[CartesianIndex(1,1), CartesianIndex(2,1)]] to get the required elements. But with the Tensor in Torch.jl I only get ERROR: getindex not defined for Tensor{Float32,2}

Currently getindex has been commented out in favour of keeping the implementation from going to slow fallbacks. This can be done fairly easily via views on the tensor. So a getindex operation can create a copy of a view.