- C++/CUDA Extensions in PyTorch
- Installation
- To build
- To test
- To benchmark Python vs. C++ vs. CUDA
- How to Contribute
- Authors
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.mymuladdcustom op that has both custom CPU and CUDA kernels.
The examples in this repo work with PyTorch 2.4+.
To use the following extension you must have the following:
- PyTorch 2.4+: Must have a compatible version installed.
- CUDA Toolkit: Required for building and running the CUDA kernels if using GPU acceleration.
- GCC or Clang: Necessary for compiling the C++ extension.
- Python 3.7+: Check you are using a compatible version of Python.
You can install the required packages using:
pip install torch
pip install -r requirements.txt # If any additional requirements are specifiedpip install .
python test/test_extension.py
python test/benchmark.py
Contributions are always welcome, to contribute remember to do the following:
- Click the "Fork" button at the top of this repository to create your own copy.
git clone https://github.com/<your-username>/extension-cpp.git
cd extension-cpp