Cdjones
MModular
•Created by Cdjones on 1/6/2025 in #community-showcase
Min Heap for Mojo
While doing this year's Advent of Code I quickly put together functions to make a min heap in mojo because I couldn't find anything in the stdlib. It works the same as the python heapq library without having to go through the hassle of python interop and runs around 6.5x faster. Currently it only supports heappush and heappop but I might add a heapify function or MinHeap struct if anyone's interested. Hope this saves someone some time.
https://gist.github.com/mehta302/ffebd938e63ae43bd5e02bac72a0cae1
1 replies
MModular
•Created by Cdjones on 9/28/2024 in #questions
LLVM ERROR: out of memory
WSL Ubuntu user with 16GB ram. Getting this error using Tensors:
3 replies
MModular
•Created by Cdjones on 7/10/2024 in #questions
Tensor Transposition
After looking through the mojo documentation for the standard library as well as external code repositories, I was unable to find functionality to transpose 2 specified dimensions of a Tensor struct, similar to what's available in libraries such as Pytorch and Numpy. I implemented my own basic function as a brute force approach that iterates through every index, switches the specified dimensions and stores it in a separate Tensor struct. Is there any better way to go about doing this?
I've been trying to look for a way to vectorize this process using SIMD as well as trying to find a way to directly mutate the tensor but can't think of any better approach. I've also tried searching for the source code that Numpy or Pytorch uses for these functions but couldn't seem to find it.
My Current Approach:
https://github.com/mehta302/Tensor-Transpose/blob/main/transpose.mojo
Benchmark:
(with 100x100x100 float32 randomized tensor switching first 2 dimensions)
1 replies