mratsim/Arraymancer
A fast, ergonomic and portable tensor library in Nim with a deep learning focus for CPU, GPU and embedded devices via OpenMP, Cuda and OpenCL backends
What it solves
Arraymancer is a fast and ergonomic n-dimensional array (tensor) library for the Nim language. It provides the necessary mathematical foundations for scientific computing, machine learning, and deep learning, filling a gap for a high-performance numerical computing ecosystem in Nim similar to what NumPy and PyTorch provide for Python.
How it works
The library implements a tensor system that supports CPU, CUDA, and OpenCL backends. It leverages BLAS and LAPACK libraries for optimized linear algebra operations. The library includes a domain-specific language (DSL) for defining neural networks, allowing users to define layers (such as Linear, Conv2D, and GRULayer) and forward passes. It also features an autograd context for managing computational graphs and performing backpropagation.
Who it’s for
It is designed for researchers and developers who want to perform numerical computing or build deep learning models using Nim, benefiting from fast compilation times and the ability to distribute projects with fewer dependencies compared to Python-based stacks.
Highlights
- Multi-Backend Support: Supports CPU, CUDA, and OpenCL for tensor operations.
- Broadcasting: Explicit broadcasting support using specific operators (e.g.,
+.). - Deep Learning Tools: Includes built-in layers for fully-connected, convolutional, and recurrent neural networks (RNNs).
- Flexible Slicing: Efficient slicing with support for ranges and steps.
- Scientific Computing: Provides PCA, K-means, eigenvalues/eigenvectors decomposition, and least squares solvers.