hasktorch/hasktorch

Tensors and neural networks in Haskell

What it solves

Hasktorch provides a way to build tensors and neural networks using the Haskell programming language, allowing developers to leverage the power of PyTorch's core C++ libraries within a strongly-typed functional environment.

How it works

It functions as a Haskell library that leverages the core C++ libraries shared by PyTorch (libtorch). It uses a low-level Foreign Function Interface (FFI) and code generation to bind PyTorch's C++ functionality to Haskell. The library automatically handles the downloading and caching of official libtorch binaries for various platforms, including support for CPU, CUDA, and Apple's MPS backend.

Who it’s for

Haskell developers and researchers who want to implement deep learning models and tensor operations using a functional programming language.

Highlights

  • PyTorch Integration: Built on top of the same C++ core used by PyTorch.
  • Cross-Platform Support: Works on Linux (CPU/CUDA), macOS Apple Silicon (CPU/MPS), and macOS Intel (CPU).
  • Automated Setup: Automatically downloads and caches required libtorch binaries during the build process.
  • Flexible Build Tools: Compatible with Cabal, Stack, and Nix.

Related

  • Project
  • Project
  • Project
  • Project
  • Project