Please make sure PyTorch (2.1.2) and cuda-toolkit (nvcc compiler) are installed.
vector_addition
: Classic CUDA C example, to compile usemake
in thevector_addition
directory.rgb_to_grayscale
: Example uses PyTorch'storch.utils.cpp_extension.load_inline
feature to compile a custom RGB to grayscale kernel and uses it to convert input image to grayscale and which is saved in asoutput.png
. Run in thergb_to_grayscale
folderpython rgb_to_grayscale.py
.mean_filter
: This example also uses the PyTorch'scpp_extension.load_inline
feature to compile a mean filter kernel. The kernel read pixel values in the surrounding (square area) of a pixel and computes the average value for each RGB channel individualy. The result is saved tooutput.png
. Run in themean_filter
folderpython mean_filter.py
.