Tensors and neural networks in Haskell
Haskell Other
Switch branches/tags
Nothing to show
Latest commit 0a54ffd Feb 11, 2018
austinvhuang Merge pull request #75 from AlejandroCatalina/add-eye
Add tds_eye to generate identity matrix



Build Status

Hasktorch is a library-in-development 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 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).

Project Organization

Directory Description
codegen/ Code generation to produce low-level raw Haskell bindings. Also includes experimental aten cwrap file parsing.
core/ Memory-managed tensors and core data types that wrap raw C bindings to TH.
examples/ Examples of basic usage and experimental prototypes
output/ Staging directory for codegen/ output, contents should not be under source control.
raw/ Comprehensive raw bindings to C TorcH (TH) operations.
vendor/ 3rd party dependencies as git submodules (links to TH C and other libraries)

Build Instructions

Currently hasktorch only supports OSX and Linux builds. Building Hasktorch requires retrieving and building C++ torch dependencies as submodules followed by building with the Stack tool. These steps are done automatically using the Makefile:

make init

For manual steps to build the project, see the developer guide for instructions and the vendor/ README for details on external dependencies.

Getting started

For an example of basic end-user API usage, see the example on statically typed tensor usage and the simple gradient descent example.

For details on implementation and usage of raw C bindings and the core library, refer to their respective README documentation in raw/ and 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 for access to the private hasktorch slack channel at:


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, Huw Campbell, and Kaixi Ruan, as well as to the Torch and PyTorch frameworks.