How can i find the c++ implementation of pytorch function

I know C++ implementation code is in the folder ATen. But how can i find C++ implementation of function such as torch.tensor.half().

In the end, you use .to, just like you would in the “modern” PyTorch idiom.

The variable function not founds in ATen can nonetheless be found using “rgrep” or somesuch on the source, in this case it is found in tools/autograd/templates/python_variable_methods.cpp or also, after you have built PyTorch in torch/csrc/autograd/generated/python_variable_methods.cpp.

Best regards

Thomas

1 Like

Thank you very very much. Follow you suggest, I found what I need. Maybe you can give me some advice about how did you find where the torch.tensor.half() it is. How can I learn more about pytorch file structure

I die use rgrep. In addition to the directory structure in CONTRIBUTING.md, you might look at an old blog-post of mine or @ezyang’s awesome talk.

Best regards

Thomas

1 Like