Gennadiy
Gennadiy
MModular
Created by Gennadiy on 12/21/2024 in #questions
Mojo equivalent of Python class parameters
In Python, you can create a class, say "model" and ask for its parameters using model.parameters. Is there an equivalent for a struct in Mojo? I would like to pass it to something like: torch.optim.Adam(model.parameters(), ...) .
5 replies
MModular
Created by Gennadiy on 12/16/2024 in #questions
Unable to use PyTorch from Mojo
I just wanted to try Pytorch and created a project using nightly build. I then installed PyTorch using: magic add "pytorch". This is the code I tried: from python import Python fn main() raises: torch = Python.import_module("torch") x = torch.tensor([1, 2, 3]) print(x) It resulted in the following error: Unhandled exception caught during execution: libmkl_intel_lp64.so.2: cannot open shared object file: No such file or directory mojo: error: execution exited with a non-zero result: 1 I can see "libmkl_intel_lp64.so.2" in the .magic\envs\default\lib folder so I do not understand what the problem is.
33 replies
MModular
Created by Gennadiy on 12/8/2024 in #questions
What is the correct way to call polynomial_evaluate?
I am trying to follow this code from Mojo 24.2 in Mojo 24.5: Newton-Raphson but I get the error: invalid call to 'polynomial_evaluate': failed to infer parameter #0. Here's is a relevant snippet of the code:
from math.polynomial import polynomial_evaluate from math import ulp alias dtype = DType.float64 alias width = simdwidthofdtype alias coeff = List[Scalar[dtype]](-6, 3, -2, 1) alias deriv_coeff = List[Scalar[dtype]](3, -4, 3) def f(x: Float64) -> Float64: return polynomial_evaluatedtype, 1, coeff
2 replies
MModular
Created by Gennadiy on 12/3/2024 in #questions
Cannot start a mojo REPL in WSL
I am following the Get Started guide here: https://docs.modular.com/mojo/manual/get-started. I have successfully completed all the sub-steps in 'Step 1: Create a new project' and running 'mojo --version' works fine. However, for 'step 2: run code in REPL', when I type 'mojo', I get the error: "unknown error".
6 replies