pascalpolygon
MModular
•Created by pascalpolygon on 4/25/2024 in #questions
Efficient Mojo Tensor To Numpy Array Conversion
Hello,
I am attempting to convert a Mojo Tensor to a Numpy array without looping or at least with sub-polynomial time.
My approach is to get the pointer to the Tensor and use Python's ctypes.from_address()
But it doesn't work - the output np_array is not the same as the tensor...maybe Tensor has some header bytes? Or the pointer does not point to a contiguous memory block?
I would like to understand the issue with this code and get some inputs on how to achieve fast conversions for potentially large Mojo Tensors.
Here is the code:
Thank you.
2 replies
MModular
•Created by pascalpolygon on 4/3/2024 in #questions
Is there a simple way to implement Numpy-style ndarray slicing on Mojo Tensors ?
I have a rank 4 tensor where the first dimension is an index and the last 3 represent a Voxel Grid.
I want to get the voxel grid given a build_id. I wrote a function to do this but I am wondering if I there's a Mojo way to do this.
2 replies
MModular
•Created by pascalpolygon on 3/13/2024 in #questions
Numpy: Import from source dir error
I am trying to import Numpy in my mojo project using
But I get the following Error:
5 replies
MModular
•Created by pascalpolygon on 2/29/2024 in #questions
Invalid Parameter to Vectorize from example
Hello!
I just got started with Mojo, been playing with in for the past 2 days. I run into an a syntax error from just copying the matmul example.
On this line
vectorize[dot, nelts, size=tile_x]()
I get the error : Cannot pass 'fn[Int](n = Int) capturing -> None' value, parameter expected 'Int'mojo
4 replies