ankane / torch.rb

Deep learning for Ruby, powered by LibTorch

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Tensor ellipsis indexing and step slicing

orlando-labs opened this issue · comments

commented

Hi, @ankane!

Working recently on some Fairseq models porting, I met the following line:

residual = residual[..., :: r_tsz // tsz][..., :tsz]

What can we do with such ellipsis indexing and step slicing while keeping Ruby clarity?

UPD: according to docs

It’s also important to note that index types such as None / Ellipsis / Slice live in the torch::indexing namespace

Hi @orlando-labs, there could probably be Torch::Ellipsis and Torch::Slice classes for this (similar to the C++ API). I'm not sure it would be especially Ruby-like, but would make it easier to port code.

commented

Looks like the only way to go.