How can I modify c++ files in pytorch?

How can I modify c++ files such as caffe2 or csrc c files? I can only find header files so that I can’t try to modify to test what I want.

Pytorch is calling methods from c++ files and I want to make changes in the c++ files such as caffe2/serialize/inline_container to test what I want to see.

I am totally lost as a starter and its been 2 weeks I am trying to get familiar with this software…

I beg your generousity.

You can find the file here and it will have the same relative location in your locally closed GitHub repository.
Manipulate the file locally and rebuild PyTorch afterwards.

1 Like

Thanks for answering! I was trying to follow the path according to the github path, but there are only headers… where can I find cpp files? I am using anaconda, would it be affecting?

You would need to git clone the repository, manipulate the file, and build PyTorch from source.
You cannot manipulate C++ files in a pre-built binary and expect to see changes without compiling the code again.

So… if I just download pytorch from their website in local or conda, I cannot find the cpp files, but headers? I have to clone their github and build pytorch by myself?

Yes, since C++ is a compiled language you would need to clone the repository and rebuild PyTorch from source. Any changes in .cpp files won’t be visible in the compiled binary.

1 Like

Thanks a lot! And could you please let me know any resources about how to recompile those c++ files after making changes to apply for pytorch?

You can follow these instructions from the repository.

1 Like