Sagi
Sagi
MModular
Created by Sagi on 5/25/2024 in #questions
math.atan funtion not working on compile time
Thanks for answering!
22 replies
MModular
Created by Sagi on 5/25/2024 in #questions
math.atan funtion not working on compile time
it was just for convenience but also I just wandered why it didn't work but the power and log2 function was important because for some image processing task I needed to use the SIMD and because it needs to be in a size of a power of 2 and given at compile time its nice that you can enter any frame size and it will round it up into a power of 2
22 replies
MModular
Created by Sagi on 5/5/2024 in #questions
How to efficiently sum a SIMD
thank you very much, I didn't notice that function
6 replies
MModular
Created by pascalpolygon on 4/25/2024 in #questions
Efficient Mojo Tensor To Numpy Array Conversion
Hi, this code worked for me although it has some problem, for some reason, the first two elements (at least from my very little tests) of the pointer are wrong, you can also confirm that by printing the pointer values in mojo, after that i just casted the pointer to a numpy array with ctypes and numpy
from tensor import Tensor, TensorShape
from python import Python

fn main() raises:

var np = Python.import_module("numpy")
var ctypes = Python.import_module("ctypes")
var mojo_tensor = Tensor[DType.int32](
TensorShape(5, 5),
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1
)
var ptr = mojo_tensor.data().__int__()
var data_pointer = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_int32))
var numpy_array = np.ctypeslib.as_array(data_pointer, shape=(5, 5))
print(numpy_array)

from tensor import Tensor, TensorShape
from python import Python

fn main() raises:

var np = Python.import_module("numpy")
var ctypes = Python.import_module("ctypes")
var mojo_tensor = Tensor[DType.int32](
TensorShape(5, 5),
1, 0, 0, 0, 0,
0, 1, 0, 0, 0,
0, 0, 1, 0, 0,
0, 0, 0, 1, 0,
0, 0, 0, 0, 1
)
var ptr = mojo_tensor.data().__int__()
var data_pointer = ctypes.cast(ptr, ctypes.POINTER(ctypes.c_int32))
var numpy_array = np.ctypeslib.as_array(data_pointer, shape=(5, 5))
print(numpy_array)

2 replies
MModular
Created by Sagi on 5/5/2024 in #questions
How to efficiently sum a SIMD
more on the over all question, i want to fastly calculate the mean squre error on two vectors in the simd, so i have 2 simd vector, let's say A and B so i need to calculate A-B and then sum the outcome, how can i do that efficiently in the SIMD?
6 replies
MModular
Created by Sagi on 9/29/2023 in #questions
PyObject support
I mean that why you do like let np = Python.import_module("numpy") let x = np.array([1, 2, 3]) Than x is PyObject, and if you want to iterate x fastly you would rather x to be Tensor, I am asking if there will be an intended way that will work fast to transfer PyObject, eve only numpy arrays into moji's Tensor
4 replies
MModular
Created by AstroLightz#0985 on 9/28/2023 in #questions
Can Mojo be installed on Linux Mint?
yap
10 replies
MModular
Created by AstroLightz#0985 on 9/28/2023 in #questions
Can Mojo be installed on Linux Mint?
10 replies
MModular
Created by AstroLightz#0985 on 9/28/2023 in #questions
Can Mojo be installed on Linux Mint?
I don't think I did something special, but I would love to share It in a Gist
10 replies
MModular
Created by AstroLightz#0985 on 9/28/2023 in #questions
Can Mojo be installed on Linux Mint?
and it's working well
10 replies
MModular
Created by AstroLightz#0985 on 9/28/2023 in #questions
Can Mojo be installed on Linux Mint?
yes, i am on linux mint and i am using the 0.3.1
10 replies