Skip to content

daknuett/extension-cpp-meson

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

36 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

C++/CUDA Extensions in PyTorch

Note meson-build

This example specifically illustrates the use of meson to build a torch C++ extension.

To build, use

python -m pip install --no-build-isolation .

Note that the --no-build-isolation is required, because the extension needs to link against the torch shared objects. When running without --no-build-isolation, it will link against the temporary torch installation which is removed after the build process is finished.


An example of writing a C++/CUDA extension for PyTorch. See here for the accompanying tutorial. This repo demonstrates how to write an example extension_cpp.ops.mymuladd custom op that has both custom CPU and CUDA kernels.

The examples in this repo work with PyTorch 2.4+.

To build:

pip install .

To test:

python test/test_extension.py

To benchmark Python vs. C++ vs. CUDA:

python test/benchmark.py

Authors

Peter Goldsborough, Richard Zou, Daniel Knuettel

About

C++ extensions in PyTorch; build using meson

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 39.8%
  • Cuda 21.4%
  • C++ 19.6%
  • Meson 19.2%