Where is the implementation of Tensor::slice?

I see Tensor::slice being called, for example, in this code.https://github.com/pytorch/pytorch/blob/master/aten/src/ATen/native/Integration.cpp

However, slice() is not listed in any of the following files



I understand that there is some code generation that is happening, and maybe that the function is being injected by a python script.

I believe it’s implenented here :slight_smile:

2 Likes

Thanks @albanD. Do you understand how the code generation mechanism works? How does it end up being a member function of Tensor? As it is declared in this file, it is a free standing function.

The bindings (at::… and Tensor member functions) are generated from native_functions.yaml – look for variants: method for members.

1 Like

Namely:

  • function means you get a torch.xxx(t) function
  • method means you get a t.xxx() function
1 Like

Thanks @tom. This is kind of a tangent, but what is the purpose of the overload_name

- func: func_name[.overload_name](ArgType arg0[=default], ArgType arg1[=default], ...) -> Return

Shouldn’t the argument list be sufficient to uniquely identify an overloaded C++ function? If an overload_name is specified, does it need to also appear in the C++ source somewhere for the code generation to work?

I am not aware of the overload name being used for C++, you certainly can access the overloads as expected.

1 Like