How can pytorch call cpp from python?

I want to do something like optimize operator or implement new operators.
But I’m new to pytorch, I watch the code like how pytorch implement relu. and I’m confused how can pytorch call the cpp file from python file?

I 'm working at developing some operators in CUDA I want to publish a paper about my job. But I’m new about this, and my professor is new,too. So If you can give some advise I will be very very thankful!

Thanks for your reply!

You can write custom C++ and CUDA extensions as described here.

Tnanks!!! I will follow this. But I want to know how pytorch work?

PyTorch uses pybind11 internally.