Modular

M

Modular

This server is the home of the MAX and Mojo community. Join us to chat about all things Modular!

Join

questions

community-showcase

Question about iterating a list of strings

Hi, I've got a background in Rust (10 years) and in Python (1 year) and I try to learn Mojo. I've try this : ```...

^ in mojo documentation?

Hello, sorry if this is an obvious question. I am new to programming and trying to pick my next language to learn for some more serious projects. I was reading through the documentation and I can't seem to understand what the ^ symbol does. I see it is a XOR in python but I am seeing it pop up in a few places where that doesn't make sense to me. For example here: https://docs.modular.com/mojo/manual/decorators/value specifically:
fn init(inout self, owned name: String, age: Int): self.name = name^ self.age = age...

equivalents of beartype and jaxytping? for runtime static type checking and shape checking

hi all! we are building local first large language models for health care based on work i did during my phd (http://arxiv.org/abs/1904.05342) and that we are now scaling through a non-profit (onefact.org). key blockers for us in porting this encoder-only and other encoder-decoder transformer-based models we have trained for health care use cases include runtime type checking and shape checking, given we work with XLA/TPU/GPU systems at various hospitals and health systems. happy to elaborate or discuss if needed, email is jaan@onefact.org and cv is jaan.io/cv 🙏 we were referred to you by core rust contributors....

Time taken in Inference session

This is my code: ``` var graph = Graph(in_types=List[Type](TensorType(DType.float32, (N * (H - K + 1) * (W - K + 1)),K * K * C_in), TensorType(DType.float32, K * K * C_in,C_out), TensorType(DType.float32, bias.shape()[0]))) var out = graph[0] @ graph[1] var out1 = out + graph[2]...

How to iterate through an array/list?

Hello, I'm coming from Java to Mojo. It seems there is no support for iterating with "for" through a list - at least in the present version of Mojo. Here's the code: ``` def createFreeformExtrusion(lines:((Int,Int),(Int,Int),Optional[(Int,Int)])[], height)->String: # currently without curves....

Stackdumps when using Python libraries such as scipy from mojo

Anybody else seeing random stackdumps happening when using eg scipy PythonObjects ? I'm using scipy.sparse.load_npz, csr_matrix() etc from Mojo. Quite frequently (but not always) I get stackdumps when running the code with mojo mymojo.mojo.

What features or libraries are you waiting for before you start using Mojo in your domain?

Just curious what the community is waiting for before they start using Mojo seriously in their domain. I'm in the Data Eng/Backend/DevOps space and I have a few I'm waiting for. Namely an HTTP client with SSL support and Database drivers to build data services/tooling. As for Mojo features, I'm excited to see file scope code support and better C FFI (for the above libraries). A clean way to call system...

Seeking Advice on Porting Python Classes to Mojo Structs

I still struggle with how to port Python classes to Mojo structs in the current state of Mojo and seek some help. Here I post a Python class and suggest four ways to port it to Mojo that I came up with. All of them work in this simple example but seem to have some major drawbacks when the class is more complex. It would be great to get feedback on how you handle this. Here an example Python class to port to Mojo...

Is it possible to store a list of References in Struct?

Calling all reference experts! I've seen some conversations lightly touching on the topic but I haven't seen anything concrete. I know I can do something like this: ```rust struct CLIis_mutable: Bool, lifetime: AnyLifetime[is_mutable].type: var commands: List[Reference[Command, is_mutable, lifetime]]...

LLVM Intrinsics

I'm trying to use llvm.matrix.transpose intrinsic like following: ```from sys.intrinsics import llvm_intrinsic fn main(): alias intrin: StringLiteral = "llvm.matrix.transpose" ...

deleted message by Mojo-Bot

Is it possible to recover a message that was blocked by mojo-bot. I shared a link in a long message posted in the general channel. I think the message was useful to the community. I would like to recover it, and remove the link.

Google Protobuf

Will mojo support with protbuf? or some network things can i use?

tqdm progress bar for Mojo?

I cant get tqdm to work via Python interface , so i am wondering if any of you managed to use it in Mojo or if we have something similar already implemented in Mojo. Thx.

Why are you using Mojo?

Just curious: why are you using Mojo? i will start with the obvious, lets see where this goes 😉...

math.atan funtion not working on compile time

is that okay that the atan funtion not working at compile time? when I try alias a = math.atan(Float32(3)) if fails with the error ...

What is the basis for Mojo's `async`?

As per the title, I'm wondering what the underlying mechanism for async libraries will be. In the community meeting, it was mentioned that async and coroutines would be areas of focus in Mojo's design for the next few months, so I think this is the right time to discuss their design. In C++, the underlying mechanism on which async libraries were built was initially chosen to be coroutines, but there's work going on right now to introduce a better alternative:
In a suite of generic async algorithms that are expected to be callable from hot code paths, the extra allocations and indirections are a deal-breaker. It is for these reasons that we consider coroutines a poor choice for a basis of all standard async....

Roadmap for classes, dynamic polymorphism ...

I noticed that object-oriented programming features like classes and dynamic polymorphins weren't addressed in the last community meeting. Given that Mojo development is tightly coupled with the Max Engine and its assumingly different requirements, I'm wondering if there is a long-term roadmap available for these features. To put it brief, will Mojo have classes in 2024? 😉 Thx...

We are producing a Chinese version of Mojo learning materials. Can it be officially recognized?

The Chinese Internet is relatively closed under certain conditions. For example, due to network problems, many people in China cannot access the official website of Modular and cannot install Modular. Therefore, we translated and produced the Mojocn.org Chinese documentation website, hoping to give Chinese users more learning opportunities. At the same time, many people in mainland China cannot use discord, so we established the mojoo.org Chinese community. In any case, we still hope to get official recognition and support from modular. ...

Mojo for Evolutionary Algorithms

hey everyone! I'm currently working on a semester project comparing the performance of evolutionary algorithms in Mojo vs python, which I plan to expand into my bachelor's thesis (if I'm able to finish it). However, I'm struggling to achieve the expected performance gains in Mojo due to some challenges with list comprehensions, creating lists of lists, and using random effectively etc. as a bachelor student, I'm quite unsure whether I should keep trying to figure out how to optimize performance in Mojo or find a new idea before it's too late. I'm curious if it's well suited for evolutionary algorithms and whether the performance gains I'm seeking are achievable without excessive difficulty. any advice on that matter would help me a lot...

Is it possible to convert an Int to a String at comp time?

Hey all, I'm trying to make some comp time friendly structs for my project. I'm struggling with converting an int to a string for some string concatenations. str() does not work at comp time. Minimal example to reproduce the error. ```mojo fn main() -> None:...