Skip to content

Modernize extension-cpp; refactor code #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 16 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,24 @@
# C++/CUDA Extensions in PyTorch

An example of writing a C++ extension for PyTorch. See
An example of writing a C++/CUDA extension for PyTorch. See
[here](http://pytorch.org/tutorials/advanced/cpp_extension.html) for the accompanying tutorial.
This repo demonstrates how to write an example `extension_cpp.ops.lltm`
custom op that has both custom CPU and CUDA kernels.

There are a few "sights" you can metaphorically visit in this repository:
To build:
```
pip install .
```

- Inspect the C++ and CUDA extensions in the `cpp/` and `cuda/` folders,
- Build C++ and/or CUDA extensions by going into the `cpp/` or `cuda/` folder and executing `python setup.py install`,
- 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,
- Benchmark Python vs. C++ vs. CUDA by running `python benchmark.py {py, cpp, cuda} [--cuda]`,
- Run gradient checks on the code by running `python grad_check.py {py, cpp, cuda} [--cuda]`.
- Run output checks on the code by running `python check.py {forward, backward} [--cuda]`.
To test:
```
python test/test_extension.py
```

To benchmark Python vs. C++ vs. CUDA:
```
python test/benchmark.py
```

## Authors

Expand Down
73 changes: 0 additions & 73 deletions benchmark.py

This file was deleted.

107 changes: 0 additions & 107 deletions check.py

This file was deleted.

Empty file removed cpp/__init__.py
Empty file.
3 changes: 0 additions & 3 deletions cpp/jit.py

This file was deleted.

44 changes: 0 additions & 44 deletions cpp/lltm.py

This file was deleted.

11 changes: 0 additions & 11 deletions cpp/setup.py

This file was deleted.

Empty file removed cuda/__init__.py
Empty file.
4 changes: 0 additions & 4 deletions cuda/jit.py

This file was deleted.

45 changes: 0 additions & 45 deletions cuda/lltm.py

This file was deleted.

Loading