libtorch_examples
libtorch_examples copied to clipboard
Examples of libtorch, which is C++ front end of PyTorch
libtorch_examples
This repository contains examples of libtorch, which is C++ front end of PyTorch.
hello_world.cpp: A simple example of libtorch.function_approx.cpp: A feedforward network based function approximator, which trains ony = cos(x).
Compilation
-
Download libtorch with cmake automatically
mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release && cmake --build . -
Use an existing local libtorch
mkdir build && cd build cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch && cmake --build .