How to create a THByteTensor in C?

I’d like to build a c extension to binarize a FloatTensor which may need to store the binarized values in a ByteTensor.
I followed this tutorials, but it didn’t talk much about the c interface of torch.
I tried to read the source code but it seems to be pretty hard for me to figure this out.
So could anyone show me an example of creating a THByteTensor, or a better way to implement the binarization?
Thank you very much !

You could look at https://github.com/pytorch/extension-ffi/tree/master/package
Particularly the .c files in there.

Thank you!
I’ve solved my problem.
https://github.com/pytorch/extension-ffi/tree/master/package 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!