/GenTorch

Work-in-progress C++/LibTorch-based Gen probabilistic programming language

Primary LanguageC++Apache License 2.0Apache-2.0

GenTorch

Test

Work-in-progress probabilistic programming language for use with GenTL, building on LibTorch.

Documentation (work-in-progress)

External dependencies

C++ compiler supporting C++17

For example, either clang++-13 or g++-11.

NOTE: The multi-threaded supervised learning function in GenTL currently requires a C++20 feature, which is implemented in gcc version 11 and above and clang version 11 and above.

CMake

See Installing CMake

libtorch

This library depends on the C++ distribution of PyTorch, called libtorch.

So far, the code has only been tested with the CPU-version of libtorch (version 1.9.1+cpu).

Follow instructions at Installing C++ distributions of PyTorch to install LibTorch, and record the absolute path to the resulting libtorch directory on your filesystem.

Doxygen

This is only required for generating documentation.

See Doxygen Installation.

Building

Currently this project builds a static library, tests, and documentation.

To build, either open the GenTorch directory in a C++ IDE (e.g. https://www.jetbrains.com/clion/) or use cmake directly. In either case, you need to add an option -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch when configuring cmake.

To configure:

cmake -S . -B build -DCMAKE_PREFIX_PATH=/absolute/path/to/libtorch

To build:

cmake --build build

To run tests:

cmake --build build --target test

To build documentation:

cmake --build build --target docs

References

Gen: A General-Purpose Probabilistic Programming System with Programmable Inference. Cusumano-Towner, M. F.; Saad, F. A.; Lew, A.; and Mansinghka, V. K. In Proceedings of the 40th ACM SIGPLAN Conference on Programming Language Design and Implementation (PLDI ‘19). (pdf) (bibtex)

Marco Cusumano-Towner's PhD thesis.