https://github.com/smrfeld/pytorch-cpp-tutorial
Tutorial for Python package calling a custom PyTorch C++ module
https://github.com/smrfeld/pytorch-cpp-tutorial
cplusplus cppextension pybind11 python pytorch
Last synced: 11 months ago
JSON representation
Tutorial for Python package calling a custom PyTorch C++ module
- Host: GitHub
- URL: https://github.com/smrfeld/pytorch-cpp-tutorial
- Owner: smrfeld
- License: mit
- Created: 2023-12-04T05:22:06.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2023-12-04T07:40:28.000Z (about 2 years ago)
- Last Synced: 2025-02-16T06:44:56.350Z (about 1 year ago)
- Topics: cplusplus, cppextension, pybind11, python, pytorch
- Language: Python
- Homepage:
- Size: 1.95 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tutorial for Python package calling a custom PyTorch C++ module
This is a minimal example of a Python package calling a custom PyTorch C++ module.
## Installing & running
0. (Optional) Create a conda environment:
```bash
conda create -n test-pytorch-cpp python=3.11
conda activate test-pytorch-cpp
```
1. Install requirements:
```bash
pip install -r requirements.txt
```
2. Install package using `setup.py`:
```bash
pip install -e .
```
3. Run the test:
```bash
python main.py
```
Expected result:
```
tensor([5., 7., 9.])
```