Skip to content

Commit 735149e

Browse files
committed
Modernize extension-cpp; refactor code
This PR: - creates a single unified build for extension-cpp (instead of having separate cpu/cuda setup.pys). - Updates the build system to use pyproject.toml (instead of only setup.py) - Uses TORCH_LIBRARY to bind operators (instead of using PyBind) There will be more future work to add improvements (e.g. torch.compile support) and also fix up the corresponding C++ extensions tutorial. Test Plan: - Refactored all of the tests under test/ [ghstack-poisoned]
1 parent 1031028 commit 735149e

24 files changed

+329
-582
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,22 @@
11
# C++/CUDA Extensions in PyTorch
22

3-
An example of writing a C++ extension for PyTorch. See
3+
An example of writing a C++/CUDA extension for PyTorch. See
44
[here](http://pytorch.org/tutorials/advanced/cpp_extension.html) for the accompanying tutorial.
55

6-
There are a few "sights" you can metaphorically visit in this repository:
6+
To build:
7+
```
8+
pip install .
9+
```
710

8-
- Inspect the C++ and CUDA extensions in the `cpp/` and `cuda/` folders,
9-
- Build C++ and/or CUDA extensions by going into the `cpp/` or `cuda/` folder and executing `python setup.py install`,
10-
- JIT-compile C++ and/or CUDA extensions by going into the `cpp/` or `cuda/` folder and calling `python jit.py`, which will JIT-compile the extension and load it,
11-
- Benchmark Python vs. C++ vs. CUDA by running `python benchmark.py {py, cpp, cuda} [--cuda]`,
12-
- Run gradient checks on the code by running `python grad_check.py {py, cpp, cuda} [--cuda]`.
13-
- Run output checks on the code by running `python check.py {forward, backward} [--cuda]`.
11+
To test:
12+
```
13+
python test/test_extension.py
14+
```
15+
16+
To benchmark Python vs. C++ vs. CUDA:
17+
```
18+
python test/benchmark.py
19+
```
1420

1521
## Authors
1622

benchmark.py

Lines changed: 0 additions & 73 deletions
This file was deleted.

check.py

Lines changed: 0 additions & 107 deletions
This file was deleted.

cpp/__init__.py

Whitespace-only changes.

cpp/jit.py

Lines changed: 0 additions & 3 deletions
This file was deleted.

cpp/lltm.py

Lines changed: 0 additions & 44 deletions
This file was deleted.

cpp/setup.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

cuda/__init__.py

Whitespace-only changes.

cuda/jit.py

Lines changed: 0 additions & 4 deletions
This file was deleted.

cuda/lltm.py

Lines changed: 0 additions & 45 deletions
This file was deleted.

0 commit comments

Comments
 (0)