Libtorch Tensor usage

What is the C/C++ version of this python code?

myTensor[:, :, :, i]

Is is this?
myTensor.index({ “…”,"…","…",i });

or this?

myTensor.index({ Slice(),Slice(),Slice(),i });

@yf225 posted the translation between the Python and C++ API in this post. :slight_smile:

2 Likes

Thanks, just what I was looking for.

We have this https://pytorch.org/cppdocs/notes/tensor_indexing.html in the docs as well :smiley:

2 Likes