C python interface

Hi, i’m very interested in the implementation details of pytorch, i’ve been trying to read some source code of pytorch but i cannot seem to find a good way, can anyone show me how pytorch integrate python with c/c++? why not use numpy for numerical computation but use c/c++ dynamic lib instead? For extending python with c/c++, which is the best choice, cffi, ctype, cython? Thanks very much!

why not use numpy for numerical computation but use c/c++ dynamic lib instead?

Because numpy does not have GPU support.

For extending python with c/c++, which is the best choice, cffi, ctype, cython?

Internally we use our own C wrapper engine: https://github.com/pytorch/pytorch/tree/master/tools/cwrap

For end-users, we recommend that they use CFFI https://github.com/pytorch/extension-ffi

4 Likes