This directory contains a number of examples of how to use the library:
-
SimpleNet
- Starting point for new users of the library
- Most basic example showing how to take a PyTorch net, save it, and couple it to a Fortran code.
-
ResNet-18
- More complex example demonstrating how to use the library with a multidimensional input.
- Convert a pre-trained model to TorchScript and call from Fortran.
-
MultiGPU
- Revisits the SimpleNet example but considering multiple GPUs.
-
MultiIO
- Considers a variant of the SimpleNet example which has multiple input tensors and multiple output tensors.
-
Looping
- In most applications we do not just call a net once, but many times. To do this in a computationally efficient manner requires some thought. This example demonstrates how to structure code in these cases, separating reading in of a net from the call to the forward pass.
To run select examples as integration tests, use the CMake argument
-DCMAKE_BUILD_TESTS=TRUE
when building and then call ctest
. Note that testing is not currently set up
for the MultiGPU or Looping example.