HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
mratsim
Arraymancer
Nim2017–2024
mratsim / Arraymancer

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

27Distinct people
54Mentions
0Explicit recommenders
1.4KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

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

GitHub

Where it is used

No documented product use was verified in the last source check.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 8–Nov 15 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/15/2026, 4:01:40 AM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year54 dated mentions

Observed mentions: 2017-12-23 10:17:49 UTC to 2024-03-29 07:59:14 UTC.

051015202017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 1 mentions; 1 submissions, 0 comments20172018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 9 mentions; 3 submissions, 6 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 9 mentions; 0 submissions, 9 comments2020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 19 mentions; 0 submissions, 19 comments20202021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 5 mentions; 1 submissions, 4 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 6 mentions; 0 submissions, 6 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2024-01-01 00:00:00 UTC to 2025-01-01 00:00:00 UTC (exclusive): 4 mentions; 1 submissions, 3 comments2024

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC110
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC936
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC909
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC19019
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC514
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC606
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101
20242024-01-01 00:00:00 UTC2025-01-01 00:00:00 UTC413

From the project README

An excerpt from the repository, fetched Nov 12, 2026.

Read the project’s introduction
Arraymancer - A n-dimensional tensor (ndarray) library. Arraymancer is a tensor (N-dimensional array) project in Nim. The main focus is providing a fast and ergonomic CPU, Cuda and OpenCL ndarray library on which to build a scientific computing ecosystem. The library is inspired by Numpy and PyTorch and targets the following use-cases: N-dimensional arrays (tensors) for numerical computing machine learning algorithms (as in Scikit-learn: least squares solvers, PCA and dimensionality reduction, classifiers, regressors and clustering algorithms, cross-validation). deep learning The ndarray component can be used without the machine learning and deep learning component. It can also use the OpenMP, Cuda or OpenCL backends. Note: While Nim is compiled and does not offer an interactive REPL yet (like Jupyter), it allows much faster prototyping than C++ due to extremely fast compilation times. Arraymancer compiles in about 5 seconds on my dual-core MacBook. Reminder of supported compilation flags: -d:release: Nim release mode (no stacktraces and debugging information) -d:danger: No runtime checks like array bound checking -d:blas=blaslibname: Customize the BLAS library used by Arraymancer. By default (i.e. if you don't define this setting) Arraymancer will try to automatically find a BLAS library (e.g. blas.so/blas.dll or libopenblas.dll) on your path. You should only set this setting if for some reason you want to use a specific BLAS library. See nimblas for further information -d:lapack=lapacklibname: Customize the LAPACK library used by Arraymancer. By default (i.e. if you don't define this setting) Arraymancer will try to automatically find a LAPACK library (e.g. lapack.so/lapack.dll or libopenblas.dll) on your path. You should only set this setting if for some reason you want to use a specific LAPACK library. See nimlapack for further information -d:openmp: Multithreaded compilation -d:mkl: Deprecated flag which forces the use of MKL. Implies -d:openmp. Use -d:blas=mkl -d:lapack=mkl instead, but only if you want to force Arraymancer to use MKL, instead of looking for the available BLAS / LAPACK libraries -d:openblas: Deprecated flag which forces the use of OpenBLAS. Use -d:blas=openblas -d:lapack=openblas instead, but only if you want to force Arraymancer to use OpenBLAS, instead of looking for the available BLAS / LAPACK libraries -d:cuda: Build with Cuda support -d:cudnn: Build with CuDNN support, implies -d:cuda -d:avx512: Build with AVX512 support by supplying the -mavx512dq flag to gcc / clang. Without this flag the resulting binary does not use AVX512 even on CPUs that support it. Setting this flag, however, makes the binary incompatible with CPUs that do not support AVX512. See the comments in #505 for a discussion (from v0.7.9) You might want to tune library paths in nim.cfg after installation for OpenBLAS, MKL and Cuda compilation. The current defaults should work on Mac and Linux; and on Windows after downloading libopenblas.dll or another BLAS / LAPACK DLL (see the Installation section for more information) and copying it into a folder in your path or into the compilation output folder. Show me some code The Arraymancer tutorial is available here. Here is a preview of Arraymancer syntax. Tensor creation and slicing import math, arraymancer const x = @[1, 2, 3, 4, 5] y = @[1, 2, 3, 4, 5] var vandermonde = newSeq[seq[int]]() row: seq[int] for i, xx in x: row = newSeq[int]() vandermonde.add(row) for j, yy in y: vandermonde[i].add(xx^yy) let foo = vandermonde.toTensor() echo foo # Tensor[system.int] of shape "[5, 5]" on backend "Cpu" # |1 1 1 1 1| # |2 4 8 16 32| # |3 9 27 81 243| # |4 16 64 256 1024| # |5 25 125 625 3125| echo foo[1..2, 3..4] # slice # Tensor[system.int] of shape "[2, 2]" on backend "Cpu" # |16 32| # |81 243| echo foo[_|-1, _] # reverse the order of the rows # Tensor[int] of shape "[5, 5]" on backend "Cpu" # |5 25 125 625 3125| # |4 16 64 256 1024| # |3 9 27 81 243| # |2 4 8 16 32| # |1 1 1 1 1| Reshaping and concatenation import arraymancer, sequtils let a = toSeq(1..4).toTensor.reshape(2,2) let b = toSeq(5..8).toTensor.reshape(2,2) let c = toSeq(11..16).toTensor let c0 = c.reshape(3,2) let c1 = c.reshape(2,3) echo concat(a,b,c0, axis = 0) # Tensor[system.int] of shape "[7, 2]" on backend "Cpu" # |1 2| # |3 4| # |5 6| # |7 8| # |11 12| # |13 14| # |15 16| echo concat(a,b,c1, axis = 1) # Tensor[system.int] of shape "[2, 7]" on backend "Cpu" # |1 2 5 6 11 12 13| # |3 4 7 8 14 15 16| Broadcasting Image from Scipy import arraymancer let j = [0, 10, 20, 30].toTensor.reshape(4,1) let k = [0, 1, 2].toTensor.reshape(1,3) echo j +. k # Tensor[system.int] of shape "[4, 3]" on backend "Cpu" # |0 1 2| # |10 11 12| # |20 21 22| # |30 31 32| A simple two layers neural network From example 3. import arraymancer, strformat discard """ A fully-connected ReLU network with one hidden layer, trained to predict y from x by minimizing squared Euclidean distance. """ # ################################################################## # Environment variables # N is batch size; D_in is input dimension; # H is hidden dimension; D_out is output dimension. let (N, D_in, H, D_out) = (64, 1000, 100, 10) # Create the autograd context that will hold the computational graph let ctx = newContext Tensor[float32] # Create random Tensors to hold inputs and outputs, and wrap them in Variables. let x = ctx.variable(randomTensor[float32](N, D_in, 1'f32)) y = randomTensor[float32](N, D_out, 1'f32) # ################################################################## # Define the model network TwoLayersNet: lay
Read the full README on GitHub

What Hacker News says

19 sources
> FFI: Can nim use a C++ class and vtables? D does it all the time, nearly every language proclaims to have the best C++ interop but only D seems to be actually able to do it. Templates, classes, structs, and more all work. Well, it depends on how you define "best". Beyond an ABI, FFI is obviously a function of the implementation rather than the language per-se. The main Nim implementation can use C++ as a backend language, and when it does, it can use any C++ construct very easily by way of the .emit and .importcpp directives. For sure, classes, structs, exceptions all work, and IIRC templates do too (although you might need to instantiate a header yourself for each concrete type or something .... haven't done that myself). This implementation also means that it can use any C++17 or C++20 construct, including lambdas and friends. Does D'
Read the rest
s C++ interop support C++17? C++20? Can you guarantee it will support C++27? Nim's implementation already does, on every single platform you'll be able to use C++27 on (as long as C++27 can compile modern C++ code; there had been backward incompatible changes along the C++ history). You can't just #include a C or C++ header and call it a day; You need to have a Nim compatible definition for any symbol (variable, macro, function, class, ...). There are tools that help you and make it almost as easy as #include, such as nimterop[0] and and nimline[1], and "c2nim" which is included with the Nim compiler is enough to generate the Nim definitions from the .h definitions (though it can't do crazy metaprogramming; if D can do that, then D essentially includes a C++ compiler. Which is a fine way to get perfect C++ compatibility - Nim does that) But Nim can also do the same for JS when treating JS as a backend. And it can basically do the same for Python, with nimpy[2] and nimporter, generating a single executable that works with your installed Python DLL (2.7, 3.5, 3.6, 3.7) - which is something not even Python itself can do. There was a similar Lua bridge, but I think that one is no longer maintained. > We also have Mir, which I haven't benchmarked for a while but was faster than OpenBLAS and Eugene There's quite a bit of scientific stack built natively with Nim. It is far from self-sufficient, but the ease with which you can use a C library makes up for it. I haven't used it, but Laser[3] is on par with or exceeds OpenBLAS speedwise, and generalizes to e.g. int32 and int64 matrix multiplication; Arraymancer[4] does not heve all of numpy's functionality but does have quite a few nice bits from scikit-learn, supports CUDA and OpenCL, and you can use numpy through nimpy if all else fails. Also notable is NimTorch[5]. laser and arraymancer are mostly developed by mratsim, who occasionally hangs out here on HN. D is a fine language, I used it a little in the D1 days, and it was indeed a "better C++" but did not deliver enough value to be worth it for me, so I stopped. I know D2 is much better, but I've already found my better C++ (and better Python at the same time!) in Nim, so I haven't looked at it seriously. [0] https://github.com/nimterop/nimterop [1] https://github.com/sinkingsugar/nimline [2] https://github.com/yglukhov/nimpy [3] https://github.com/numforge/laser [4] https://github.com/mratsim/Arraymancer [5] https://github.com/sinkingsugar/nimtorch
In Java is better than C++ for high speed trading systems
As someone who uses TF/PyTorch/JAX and numba for their day-to-day DL work, I've been watching Julia's post-hype developments in this area intently. Julia has probably the most vibrant ML ecosystem of all the non-Python languages (remind me when someone has implemented a transformers library for Arraymancer [1]), and absolutely smokes Python in certain niches (e.g. neural ODEs and more under the SciML [2] umbrella, I'd argue Python is "lagging hard" there). Numba can work for speeding up simple operations, but is rife with limitations that prevent optimizing more idiomatic Python code and is an absolute pain to debug. Likewise, trying to decipher or even catch errors from deep in the C++ bowels of most modern DL frameworks is an exercise of frustration. Python may still be the best language for non-cutting edge deep learning, but we ought
Read the rest
to consider whether we've overfit our algorithms to the limitations of the current system [3]. [1] https://github.com/mratsim/Arraymancer [2] https://sciml.ai/ [3] https://news.ycombinator.com/item?id=20301619
In Nim – version 1.2.6 and 1.0.8 released
> Syntax wise Nim it is a step back. It's hard to read and understand while any C/C++ dev will have next to no effort reading through D code. And of course while D is C ABI compliant it interoperates with C++ well too. On the other hand, people coming from Python, Ruby, Pascal, Ada will appreciate the minimal amount of sigils. > I seriously doubt that Nim or any other language in this regard has better metaprogramming than D. Can you write an Embedded DSL + compiler running at compile-time in D - https://github.com/numforge/laser/tree/master/laser/lux_comp... Can you write a cryptographic library with hex conversion to big integer and modular arithmetic running at compile-time in D? - https://github.com/mratsim/constantine/blob/master/constanti... Can you generate a state machine that lowers down to optimized computed gotos with no dynami
Read the rest
c allocation suitable for multithreading runtimes and embedded devices and able to display the actual graph at compiletime? - https://github.com/mratsim/Synthesis Can you describe x86 opcodes in a declarative way for a JIT assembler and do all the rex/modrm/sib computation at compile-time? - https://github.com/mratsim/photon-jit/blob/master/photon_jit... And the same thing for an emulator? - https://github.com/mratsim/glyph/blob/master/glyph/snes/opco... Can you implement async as a library? Can you emulate classes with ADTs to solve the expression problem, avoid cache misses and multithreading problem due to OOP and the double indirection due to the visitor pattern? - https://github.com/mratsim/trace-of-radiance/blob/master/tra... > Nim might have a speed overhead in certain tasks but that depends on a benchmark. Besides, does Nim have anything similar to NumPy which is actually faster? D does. It does: - https://github.com/mratsim/Arraymancer With CPU, OpenCL and Cuda backends (in differing state of maturity) and it's being used for data analysis for example ancestry prediction: - http://home.chpc.utah.edu/~u6000771/somalier-ancestry.html You can even run a neural network and see its training live: - https://github.com/Vindaar/NeuralNetworkLiveDemo AFAIK D doesn't have any plotting library while Nim has plot.ly integration and a ggplot2 port in pure Nim: - https://github.com/brentp/nim-plotly - https://github.com/Vindaar/ggplotnim And lastly nim can easily call Python: - https://github.com/yglukhov/nimpy or be called from Python: - https://github.com/Pebaz/nimporter
In Ray Tracing in Nim
He missed two that I think are really important. 1. Arraymancer https://github.com/mratsim/Arraymancer 2. The new version of the garbage collector understands move semantics to optimize its reference counting so unlike Rust where you have to deal with it yourself Nim will handle it for you at the expense of a reasonable amount of memory. https://youtu.be/yA32Wxl59wo?t=855 Watch the whole video for more context if you care. I think it's a really nice language, too many pragmas but still really nice.
In Pros and Cons of Nim
That's why you have people working on Halide, Taichi, DaCe, Tiramisu. - https://halide-lang.org/ - http://taichi.graphics/ - http://spcl.inf.ethz.ch/Research/DAPP/ - http://tiramisu-compiler.org/ This way you can have a researcher implementing the algorithm (say bilinear filtering) and a HPC expert who tunes it with parallelism, SIMD, tiling. I wrote an overview of most DSL for high performance or image processing in this issue: https://github.com/mratsim/Arraymancer/issues/347#issuecomme...
In Old box, dumb code, few thousand connections, no big deal
As girvo mentioned, compile times are really fast. Might not be as fast if you're heavy user of metaprogramming but it's still really good. For example see: https://github.com/mratsim/Arraymancer in the README it mentions: > Note: While Nim is compiled and does not offer an interactive REPL yet (like Jupyter), it allows much faster prototyping than C++ due to extremely fast compilation times. Arraymancer compiles in about 5 seconds on my dual-core MacBook.
In Vim rendered on a cube for no reason

Showing the 15 most recent of 19 sources. Enable JavaScript to search and browse every indexed mention.

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.