Thank you!
I’ve solved my problem.
https://github.com/pytorch/extension-ffi/tree/master/package 6 helped a lot. It is in fact an example about how to create an c extension.
What I really need are DOCs about TorcH’s c api but I can’t find some.
Now I’m trying to read the TH source code.
And thank you again! PyTorch is great!