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 from a simple
||Reexports of all typeclasses (see
||Reexports and helpers of the
||Typeclasses and helpers which consist of a user-friendly Haskell API|
||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|
||Comprehensive raw bindings to C operations (TH, THNN, THC, THCUNN)|
||Code generation to produce low-level raw Haskell bindings|
||Staging directory for
||3rd party dependencies as git submodules (links to ATen and, possibly, other libraries)|
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.
Ensure that libATen.so is on your library path. This can be done by sourcing the
setenv file or configuring cabal from
~/.cabal/config. Now you can build hasktorch:
cabal new-build all cabal new-run static-tensor-usage
For details on implementation and usage of raw C bindings and the core library,
refer to their respective README documentation in
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.