pytorch / extension-ffi

Examples of C extensions for PyTorch
258 stars 70 forks source link

FYI: This will not work in PyTorch 0.5 #19

Open ezyang opened 6 years ago

ezyang commented 6 years ago

We are doing a major refactor of the underlying TH libraries, which means that most of the C API will no longer work. Please see https://github.com/pytorch/extension-cpp for the replacement.

bwesen commented 5 years ago

I tried to go the "extension-cpp" route when porting stuff from the old C extension API, but it looks just hideously complicated (at least the examples there).

Are anyone aware of any bare-bones example doing a "hello world" CUDA extension using the new API, kind of like this repository does? Or a migration guide?

soumith commented 5 years ago

the cuda example looks more complicated? https://github.com/pytorch/extension-cpp/tree/master/cuda

(I am just checking if you are looking at all folders or just the cuda folder, as that's the equivalent of "hello world" CUDA extension)

bwesen commented 5 years ago

the cuda example looks more complicated? https://github.com/pytorch/extension-cpp/tree/master/cuda

(I am just checking if you are looking at all folders or just the cuda folder, as that's the equivalent of "hello world" CUDA extension)

Thanks, yes I looked through the cuda example.. After a closer look, I do know I can work through it, I was just kind of surprised that the "most simple" example chosen was a fairly complex piece of machinery with several kernels, forward/backward pass integrations, and an accompanying thousand rows long tutorial :)

What I had expected was an example of how to get a simple CUDA kernel adding two tensors into a third (for example) into pyTorch, with as little code or talk or even flexibility as possible. But don't worry I got it covered for myself, maybe I can write another barebones example and submit later.

Just to be clear, the new tutorial seems to be very well written and immensely usable when writing those full modules but kind of overwhelms you if all you want to do is accelerate a small missing op in CUDA and attach it to pyTorch.