How to learn to write C or CUDA extensions for pytorch?

This offical tutorials are not very concrete, http://pytorch.org/tutorials/advanced/c_extension.html
Any other materials for learning. I want to know how the functions like THFloatTensor_resizeAs
in C are defined and implemented then I can run my custom layer? what should I do ?

There’s a new C++ extension interface, coming in Pytorch 0.4 (and currently on master). Here are the docs for it. You can’t write CUDA extensions yet, but C++ extensions with our ATen backend work.

@richard hello. I wrote cuda extesion in 0.2 and 0,3, however, when upgrade to 0.4, the compling script install.bash can’t work… This error show up:

/torch/lib/include/TH/THAllocator.h:6:28: fatal error: ATen/Allocator.h: No such file or directory

any suggestion ? Thanks.

add -I ${TORCH}/lib/include -std=c++11 to the end of your nvcc cmd

1 Like

I am not sure if the extensions for 0.2, 0.3 versions will work with 0.4.1 onwards.
You may have to rewrite it using ATen library probably.

Thanks. It works for me.