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 that 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).
In order of high-to-low level. The reverse order can also be seen in the
||Examples of basic usage and experimental prototypes|
||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|
||Beginnings of a model zoo|
Currently hasktorch only supports OSX and Linux builds because these are what the development team works on -- if you would like to add *BSD or Windows support, please let us know!
Building Hasktorch requires retrieving and building a fork of pytorch's ATen library dependency. Currently (04/12/2018), we fork ATen to reintroduce some C-native broadcasting functionality which was moved to ATen's C++ core. This step has been condensed in our Makefile as
Following this, you will need cabal-install > 2.0 for
new-build and backpack support. If you would like to
new-run the examples on the command line (instead of dropping into a
new-repl) you will need to build off of the cabal's head (here's the current commit). If this seems intimidating, wait for backpack support in stack.
Now you can build hasktorch:
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
For more development tips, see DEVELOPERS.md and review the [
vendor/][vendor] readme for details on external dependencies.
For details on implementation and usage of raw C bindings and the core library,
refer to their respective README documentation in [
core/][core] package directories. Additional examples can be found in
examples/ as well as the test modules.
We welcome new contributors. For a rough list of outstanding items on deck (there are many places to contribute), refer to:
Contact Austin Huang or Sam Stites for access to the hasktorch slack channel. You can find our contact information by digging through cabal files or you can ping us on gitter in the DataHaskell Lobby.
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.