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

Compile time properties?

Is it possible to make compile-time properties for structs? Mojo doesn't seems to support @property right now. So the only way to implement custom properties in mojo right now is to use the __getattr__() function, which isn't a performant solution. I want to make some vector classes that support "swizzling" like in GLSL (e.g. Vec3(1,2,3).xz gives Vec3(1,3)). I achieved this in Cython by generating every possible combinations (about 50k lines). But I think with advanced parameterization in mojo, this can potentially be much simpler while keeping maximum performance....

Iterables

Have trying out iterables (iter(self)) and for most part they already work. The only thing is that they are supposed to throw a "StopIteration" exception when done. Seems that exception is not yet exposed in the Mojo SDK. Also when raising an exception, Mojo forces you to catch them at the caller side, which is not what you want when iterating. ...

tensorflow & opencv

Hey, new to mojo as of this week (using wsl2 Ubuntu)! Have any of you attempted using tensorflow or opencv in mojo? I am interested in Unets and am wondering if mojo can be used for such an applications.

Company Profitability

For as amazing as the Mojo language is I can’t help but ask where the profitability of Modular lies. I see no sales or price point in anything yet it has quite a substantial valuation. I’ve read the origin story a million times “Motivated by a desire to accelerate the impact of AI on the world by lifting the industry towards production-quality AI software, they founded Modular” but I can’t find what’s going to keep Modular afloat in the long road. Is Mojo eventually going to have a paywall? Will...

How do I use or import top-level python functions in Mojo?

How would I use top-level python functions like round() and map()?

Should the language server warn about this case?

Consider the following code:
fn f() -> Int:
<body>
fn f() -> Int:
<body>
...

Which libraries should I use for building an ANN with Mojo?

Hello guys, I was thinking about creating an ANN model with Mojo, for such, which libraries do you recommend for me to use? I'm pretty much a beginner into this aspect of AI Development, and I'd like to dive even further, even though the country I live in doesn't have much opportunities for jobs like AI. (Brazil)

Writing a server in mojo

Hi - I want to expose a mojo program via a small http server. Is there a way to do this natively in mojo (i.e do the networking stdlibs exist)? If not, can I use python to do this within mojo?

Code navigation in vscode

Folks, any vscode user here? Something I used a lot with other languages is using the Peek option to go to class/function definition. But it does not work for mojo. I have the official plugin installed. Is there something I missed?

Confusion with owned integers

I tried the replacing String from the example in the docs and got an error when running build. Docs example ``` fn set_fire(owned text: String) -> String:...

UniversalExceptionRaise - (os/kern) failure when running montecarlo with high number of samples

Hey guys, I am trying to implement a pi estimator using a montecarlo simulation. It works when I use relatively small Ns but when I put N > around 100,000,000 it gives the following error ```Please submit a bug report to https://github.com/modularml/mojo/issues and include the crash backtrace along with all the relevant source codes. Stack dump: 0. Program arguments: mojo run /Users/andreafranceschini/Documents/Coding/utils/est_pi_fast.mojo...

memory consumption

Been using mojo via vscode (using m1 mac), after running through few example codes from the site, memory consumed with vscode explodes. When i check my activity monitor i see “mojo-lsp-server” consuming a huge chunk of my available memory. What might be causing this?

cannot bind generic !mlirtype to memory-only type

Have been playing with Mojo a bit and like it a lot so far. But one area I feel I'm missing out on something is Arrays. I implemented a simple Array struct using Pointer. Simple and straightforward to implement and fast. However Pointer only works with mlirtype, not my own structs. One solution is to decorate my struct with @register_passable("trivial"), but I feel there might be a more elegant solution. Any tips?...

scope of iteration variable

```python fn main(): var i: Int for i in range(3): ......

Populating values of tensor

Currently working on creating a one-hot encoding input tensor by initializing the tensor with zeros, and then setting individual cells of the 2D tensor to 1. However, trying to set the value with tensor[i][j] = 1 is setting whole rows of the tensor at a time; how can I do this?

Mojo is faster using swap memory than regular Python is on RAM?

Has performance testing been done using Mojo with an NVMe swap file? Given the number of threads in modern processors, it seems most scale problems are RAM-constrained. NVMe is 10x slower than DDR4 RAM, but 60x cheaper. For example, a single 4TB stick of NVMe costs $166 on Amazon right now. If you combine this expansive capacity with the speed of Mojo, then it would effectively eliminate the "doesn't fit on my laptop" problem, and remove some of the need for distributed computing frameworks like Spark/Dask/Julia-Dagger....

Is it possible to use gcc like compiler flags? (ex. -ffast-math)

Some solutions implemented on C & Zig uses compiler flags to achieve tangible perfromance boost when leveraging compiler flags for optimiations. gcc (-Ofast): ``` gcc -Ofast ...

redefinition of symbol named '$< ... >'

A compiler error that took me a while to figure out. So happy to share how to solve this. Error: ```./dainemo/utils/activations.mojo:0:0: error: redefinition of symbol named '$activations' ./dainemo/utils/activations.mojo:0:0: note: see current operation: ...