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

Reading Tensor From File

Is anyone aware how the Tensor.fromfile() function works as explained in the mojo docs? I've tried reading from txt and csv files as well as files generated by the Tensor.tofile() function but none of these seem to create a Tensor with any desired values....
No description

Mojo Build size

Why mojo builds have such a size? Even simple Hello World programs have around 4 mb sizes. I first thought it might me my issue but the guy on this video also faced with it: https://www.youtube.com/watch?v=Bt3BVjW8FoY Compared to C builds, it's a lot. Isn't this an issue for a system programming language?...

Struct wrapping Python object

Please excuse me if this is a really noobie question, I'm just picking up the language... I'm trying to port an old GUI application I wrote in Python using Pyglet. My plan is currently, assuming there are no Mojo GUI library, reimplement all of the data processing in Mojo with an interface to Python to draw the UI. The first pattern I imagined would be something like:...

Is MAX real-time safe? (Or can it be configured to be?)

Hey all! Working in real-time audio applications! Just wanted to ask out-right, is MAX real-time safe? (Or can it be configured to be?) I currently work with other frameworks like onnxruntime and libtorch in C++ to deploy models but I'm forced to do some non-ideal background thread inference and use lock-free queuing between the background thread and audio thread due to those runtimes not being real-time safe. It would be a game changer if the MAX engine was real-time safe. I would probably use the C API as there's no C++ API yet right?...

Interacting with Desktop Files such as .pdf documents

Hello all, first time poster here. I've been learning mojo for about a month and I'm having an issue trying to open a .pdf file using just Mojo, no Python (likely not supported at this time?) following this guide: https://docs.modular.com/mojo/stdlib/builtin/file/ Am I missing something here or is reading content from a .pdf file not possible a this time?...

Reliability of Niche Optimizations

Is this behavior that I can rely on? I'm going to write some code that will blow up spectacularly on ARM if this is ever not true.
sizeof[Optional[fn(...) -> ...]]() == sizeof[UnsafePointer[_]]()
sizeof[Optional[fn(...) -> ...]]() == sizeof[UnsafePointer[_]]()
...

Possibility or timeline for backend framework for Mojo.

Is there a roadmap for a backend framework for Mojo/Max. I believe that this could change the language popularity and usage for good??

Is this broken or is it me? Parameterized function alias...

``` alias ExampleFn = fn [L: Int] (Int32) -> SIMD[DType.uint8, L]; fn example_fn_1 [L: Int] (default: Int32) -> SIMD[DType.uint8, L]: return SIMDDType.uint8, L;...

Autodiff For Mojo

Is there some kind of way to autodiff through functions in Mojo? This is very convenient in my line of work.

What type is the Mojo Parser? PEG?

Hello, I was curious about the parser of Mojo. Is it a PEG parser like Python? how was it built?

Error while importing local python file

Hi I was doing some experiements with python and mojo but when I tried to import the local file I got the following error:
Unhandled exception caught during execution: No module named 'python_curl'
mojo: error: execution exited with a non-zero result: 1
Unhandled exception caught during execution: No module named 'python_curl'
mojo: error: execution exited with a non-zero result: 1
Here is the code: ```python...

Its possible to create SIMD vector at runtime

I am currently working on a vector implementation using SIMD and I am encountering a challenge. Specifically, I am unable to locate an example demonstrating how to initialize an SIMD vector at runtime. Here is the relevant code snippet I am working with: ```cpp...

MLIR Docs

I've tried checking out the official MLIR website as well as the OurBool notebook but can't seem to find any info on certain bits of MLIR used in Mojo. e.g. lit and kgen are dialects used in the Mojo compiler if I understand correctly but they aren't documented anywhere I can find. Am I missing something or does Modular have some in house dialects that aren't publicly documented? Any plans to document them if so?

Is there a (N-D) contiguous data structure for non-trivial structs?

I need a data strucuture that is a 2-dimensional array of (inline) lists of pairs. That is, if subdata = data[i][j], then subdata is a dynamic data structure that contains tuples of size 2. My take on solving this was to use a Tensor for the 2-D data structure, an InlinedFixedVector for the flexible part, and a StaticTuple for the pair. ```mojo...

Difficult Trait Conformance

I have been using mojo nightly mojo 2024.8.305 (f99b2e40). I need someone's help on why this doesn't work: ```mojo trait IterDataPipable: fn next[T: CollectionElement](ref[_] self) -> Optional[T]: pass ...

Interfaces or Abstract Classes

I am learning the language, coming from .NET and Python. I am trying to implement a feature that is only aware of the of signature of another feature, and isn't concerned with its implementation details. Naturally, I reached for the traits system, but hit a brick wall because I found out you can't specify the return type of a function to be a trait, and I don't think you can specify a variable's type to be a trait either. I got partly around this writing a function that takes in the trait......

How can I write asynchronous code?

How can I implement asynchroneous code in mojo (using async etc.)? In the Changelog, I find the following example (slightly adjusted): ```mojo...

How to overload methods of generic structs to target particular types

Consider the snippet below: ``` struct Wrapper[T: CollectionElement]: var value: T...

Any way to work around that capturing closures cannot be materialized as runtime values?

I'm trying to implement converting data from an existing, possibly nested data structure into native Mojo collections like List, Dict etc. in a generic way. Here's an example for lists with one approach i've been trying: ``` @value struct Column[T: CollectionElement]:...

Hey All! I'm trying to convert an existing python code into mojo which uses jpype for java interop

I ran the code and it said "Java integration is not available in Mojo. Please run the Java part separately." does anyone have experience running code in another language from mojo with low latency?