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 to convert string to float value?

Is there any way to convert string like "3.14" to float value? I can see atol is there for converting string to int value but couldn't find anything for float values.

Implementing a simple lookup matrix

I have a precomputed (=handwritten) simple matrix that I want to use in my code. I have currently written it as follows (without a type): ```python let conversion_matrices = [ #LEFT...

When I type left round bracket code tabs to the left. Why?

I've downloaded every extension to mojo. Idk what is the problem 😦

TPU Architecture

Does Mojo utilize external TPU hardware such as the Coral USB accelerator? If not, are there future plans?

Arg parser

Hi!, I am looking for a way to build a cli tool, is there currently a way to create arguments or com

Any ideas on implementing linked based structs in mojo?

I’m working on data structures in mojo and hit a roadblock at objects like linked lists and trees, how would I code a pointer to another object of the same type in mojo? and is there a way to use DTypePointers to ensure the result is string able?

How to cast SIMD when the size is known at compile time

In the following minimal code snippet v cannot be assigned to v2. The error message is: cannot implicitly convert 'SIMD[si32, size]' value to 'SIMD[si32, 32]' in 'let' initializer. But size is known to be equal to 32. Question: how to convince the compiler that I'm a good citizen: trust me, this is ok, everyting will be fine...
```python...

Help with sort: it does not seem to do anything.

I'm a bit confused, I have a very simple sort example, but it does not do anything at all. I must be doing something wrong, because I cannot image that I'm the first to touch this code. What is going on here? The following code gives as output: ``` mojo bug1.mojo before: 0 13 76 46 53 22 4 68 68 94 38 52 83 3 5 53 67 0 38 6 42 69 59 93 85 53 9 66 42 70 91 76...

What to use for the permutation mask in SIMD.shuffle?

The following code snippet works; it is however not very convenient, especially when the SIMD width is a parameter. ```python fn swap[T: DType, s: StaticIntTuple[16]](v: SIMD[T, 16]) -> SIMD[T, 16]: let x = v.shuffles[0],s[1],s[2],s[3],s[4],s[5],s[6],s[7],s[8],s[9],s[10],s[11],s[12],s[13],s[14],s[15]...

How to build the mojo packages for my hardware?

The packages for mojo are not prebuilt for my hardware. How can I build them?

simd_load of Tensor with StaticIntTuple

How is simd_load of Tensor type supposed to work with multiple indices? This example ```python test = Tensorfloat_type for i in range(10):...

Should a newcomer to writing highly performant code skip CUDA C++ ?

I'm thinking long term about my ML journey and where ML seems to be headed, and I feel that signs keep pointing that I should invest a lot of time in grokking Mojo & MAX. Perhaps writing some CUDA C++ and reading a lot, potentially to reimplement in Mojo would be useful exercises?...

Get Date/Time in Native Mojo

Is there a library for this? The only way I can think to implement is with a python module import.

c++ interop in executables

I want to work on making a small qt interop binding with Mojo which will require c++ interop. My question is: when I compile my binary executable, will the necessary c++ files get compiled and added to the binary as well (so it can be distributed)? Can I static linking them and add them to the executable? What will distribution look like for mojo files?

Difference between Float32 and DType.float32

I don’t have a ton of experience with python or AI/ML and so trying to figure out this basic questions in the comments around the difference / similarity between Float32 and DType.float32 more context in this snippet: ```mojo let dtp = DTypePointerDType.float32.alloc(10) let p = Pointer[Float32].alloc(10)...

Building Shared and Dynamic library

Can I build an executable and a library with mojo lang or executable only?

Traits

Reading the current documentation about Mojo traits, they seem more like Java/C# interfaces that has to be implemented at type definition. Is there any plan for something similar to Rust traits/Swift protocols which can be implemented both at type and trait definition sites? They can also have mutiple implementations for non-overlapping subsets of concrete types of a generic type depending on some type parameter bound.

can I implement a trait for a third party type?

Am I right in my understanding that I can’t implement a trait I control for a type that I don’t control? For example I couldn’t implement a trait requiring an addition operator for any built in integer types? This is a point of difference with Rust traits and Haskell type classes?