NuMojo’s got NDArrays! 🥳

NuMojo has just released v0.1 adding many new features the largest of which is an N dimensional array type completely independent of Tensor. Our NDArray has many features including * Native Vectorization of arithmetic dunder operations +,-.*./ etc. * Indexing with both integers and Slices (though mixed requires using Slice explicitly due to Mojo parser limitations). * sum, mean, stdev both on axis and cumulative. * A few different matmul implementations. * Basic integration trapz. * A few of the array creation routines from numpy: arange, ones, zeros, identity. * Some Sorting functions: bubble_sort, quick_sort,and quick_sort_inplace. Our math functions were all migrated to NDArray, and a new Backend was added. VectorizedParallelizedNWorkers which allows the number of workers to be set as a parameter. I have found that setting the number of workers to between half, and three-quarters of the total number of cores provides a speed-up where default parallelization caused a slowdown (on WSL). For those of you who are new to NuMojo Backend is a trait that defines how calculations get carried out for many of the functions in our math module. The default is Vectorized which uses SIMD vectorization. In the future, all numojo functions and data types will implement backends to enable easy switching between computational methods and eventually even hardware accelerators such as GPUs. Example: The following calculates the square root of an array from 0 to 99, reshaped to 10x10, vectorized, and parallelized with 8 workers.
import numojo as nm
alias backend = nm.VectorizedParallelizedNWorkers[8]
def main():
var array = nm.arange[nm.f64](0,100)
array.reshape(10,10)
var res = nm.sqrt[nm.f64,backend=backend](array)
print(res)
import numojo as nm
alias backend = nm.VectorizedParallelizedNWorkers[8]
def main():
var array = nm.arange[nm.f64](0,100)
array.reshape(10,10)
var res = nm.sqrt[nm.f64,backend=backend](array)
print(res)
GitHub
GitHub - Mojo-Numerics-and-Algorithms-group/NuMojo: NuMojo is a lib...
NuMojo is a library for numerical computing in Mojo 🔥 similar to numpy in Python. - Mojo-Numerics-and-Algorithms-group/NuMojo
4 Replies
mad alex 1997
mad alex 1997OP5mo ago
For more information and some examples check out Our Benchmarks and Examples Repo. This update is just the beginning, PRs, and feature requests are welcome. If you would like to join our little team we also have a discord server which can be found on our GitHub (the bot doesn't like the links).
benny
benny5mo ago
Hey Alex, really great stuff. I noticed the matmul implementation is copied from Basalt, completely fine, love to see it working in other places. Since it is licensed under the apache license, i’d ask that you add atleast a comment somewhere in the file indicating that. I can’t wait to see what else you guys can make 👍🏻
PhoToN 飞得高
Hey @benny sorry for the that, that passed the radar. We were testing your implementation (which is really fast!) and it’s not part of NuMojo right now since we don’t have some compile time stuff and can’t be used. I will remove it for now and We will add the acknowledgment once we integrate it in later version! Thank you for understanding!
benny
benny5mo ago
All good, no negativity whatsoever, what you guys are doing is awesome and i’m glad to see all these changes, big fan of the project 👍🏻👍🏻
Want results from more Discord servers?
Add your server