This is a minimal example of a Python package calling a custom PyTorch C++ module.
-
(Optional) Create a conda environment:
conda create -n test-pytorch-cpp python=3.11 conda activate test-pytorch-cpp
-
Install requirements:
pip install -r requirements.txt
-
Install package using
setup.py
:pip install -e .
-
Run the test:
python main.py
Expected result:
tensor([5., 7., 9.])