How to understand C FFI extensions in Pytorch

Hi all,

Some days ago I started to read a paper about a specific orderless pooling layer that can be used mainly for texture and material recognition.

Fortunately, the paper has a publicly available Pytorch implementation.

This implementation is written as a custom C extension for Pytorch.

When I started to read the code, I became a little confused.

It seems that the code is using THC library which belongs to cutorch that is a CUDA backend for torch.

For example in the lowest level of that implementation (see this file), there are things like THCState and THCTensor variables that I couldn’t find any documentation about them.

Could someone give me a clue please?

Thanks.

1 Like

Hello,

You can read this blogpost as an introduction for why you did not found THCTensor declaration (it’s a macro). All these libs for pytorch can be found in this subfolder.

1 Like

It’s strange that I couldn’t find these references before, Many thanks.