Hasktorch is a library for tensors and neural networks in Haskell. It is an independent open source community project which leverages the core C libraries shared by Torch and PyTorch. This library leverages cabal new-build and backpack.
Note: This project is in early development and should only be used by contributing developers. Expect substantial changes to the library API as it evolves. Contributions and PRs are welcome (see details below).
||Examples of basic usage and experimental prototypes (recommended starting point)|
||Beginnings of a model zoo|
||Reexports of the high-level interface to basic tensor creation and math operations and manages allocation/deallocation via foreign pointers|
||Orphan instances of the above typeclasses for the relevant backpack signatures|
||Backpack signatures which line up with the generated C-FFI|
||Memory-managed tensors and core data types that satisfy global and type-specific backpack types|
||Submodule for low-level C ffi|
Due to the Torch Aten C++ library dependency and use of new cabal functionality with backpack, the setup process can be a bit more involved than a typical haskell library. Don't hesitate to reach out to the development team for questions or issues with getting setup (see "Contributing" below).
Currently hasktorch only supports OSX and Linux builds -- if you would like to add *BSD or Windows support, please let us know!
To get started building and testing the library:
make initwhich uses the Makefile to build PyTorch's ATen library dependency.
- Install cabal-install > 2.2 for
new-buildand backpack support if it is not already installed. We would like to support stack in the future, but that is pending the completion of backpack support in stack. Note stack can still be used as an installer for a new version of cabal-install using
stack install cabal-install --resolver lts-12.21.
- Build Hasktorch and run an example:
cabal new-build all cabal new-run static-tensor-usage
To build without GPU support/CUDA, use:
cabal new-build all --flags=-cuda cabal new-run static-tensor-usage --flags=-cuda
To launch a repl with a project (
static-tensor-usage example here), use:
cabal new-repl static-tensor-usage
Examples to Get Started
We welcome new contributors. For a rough list of outstanding items on deck (there are many places to contribute), refer to:
Thanks to all hasktorch developers who have contributed to this community effort so far. This project is also indebted to prior work on typed functional programming for deep learning by Justin Le , Edward Yang , Huw Campbell , Kaixi Ruan , and Khanh Nguyen , as well as to the Torch and PyTorch dev teams.