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

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: ...

mojo and c++ interop

Hi, I was wondering if it is possible to call foreign c++ libraries from Mojo? Thanks...

List of memory-only structs

I am trying to create a struct for a neural network layer with memory-only list of neurons: ``` struct Neuron: '''Implementation of a neuron.''' var weights: Tensor[DType.float64]...

MLIR syntax

In the low level IR in mojo tutorial I saw this line return Self(__mlir_op. index.cmp.[pred=#index<cmp_predicate eq>])(lhsIndex, rhsIndex)) I'm just a bit confused as to what #index<cmp_predicate> does. I wanted to try to make structs that use a different MLIR dialect. But because I found this syntax confusing I don't really know how I could generalize this....