1.5 New Indexing API


With the 1.5 version, we finally have API parity between Python and c++ and it’s awesome.
I would like to know if this could mean simpler code in my use cases, I’ve never used python API and I don’t really understand the syntax.

Here’s how I do it for now
From a 3d tensor, I extract the first and last columns of the dimension number 1

torch::cat({lstmOut.narrow(1,0,1).squeeze(1), lstmOut.narrow(1,lstmOut.size(1)-1,1).squeeze(1)},1);

Thank you