This repository contains all of the work leading up to Haskell support of PyTorch's C++ API (part of PyTorch's 1.0 release). It is now merged into hasktorch, where development on this work continues.
Work on ffi bindings into the c++ libtorch library in preparation for 0.2 which targets the pytorch's post 1.0libtorch backend.
General approach is to use generated Declarations.yaml spec instead of header parsing for code generation.
codegen/- code generation, parsesDeclarations.yamlspec from pytorch and producesffi/contentsdeps/- submodules for dependencies - libtorch, mklml, pytorchexamples/- high level example models (xor mlp, typed cnn)ffi/- low level FFI bindings to libtorchhasktorch/- higher level user-facing library, calls intoffi/, used byexamples/inline-c/- submodule to inline-cpp fork used for C++ FFIspec/- specification files used forcodegen/
deps/ holds several external dependencies that are retrieved using the deps/get-deps.sh script.
This should be run prior to building
The following steps should run the xor mlp example:
# Download libtorch-binary and other shared library dependencies
pushd deps
# For CPU
./get-deps.sh
# For CUDA-9
# ./get-deps.sh -a cu90
# For CUDA-10
# ./get-deps.sh -a cu100
popd
# Set shared library environment variables
source setenv
stack build examples
stack exec xor_mlp
Code generation is used to build low-level FFI functions.
Note that the code is already generated in this repo under ffi, running this is only needed if changes are being made to the code generation process.
To run:
stack build codegen
stack exec codegen-exe
To get CLI options:
stack exec codegen-exe -- --help
See the wiki for developer information.
Contributions/PRs are welcome.