voice channels
Could we please have a few voice channels in this Discord server? I'd love to just park in a channel, muted, and then unmute to chat with peeps about Mojo as some kind of general voice forum. Because I have issues. 😂
Accessing C struct members from external_call
Does Mojo's Foreign Function Interface already support calling C functions that return C structs? If so, how to access the struct's members? Isaiah Norton's call_div example (https://github.com/ihnorton/mojo-ffi/blob/ffi-demo/mojo-call-c/call_div.mojo) seems to show it is possible, but I'm unable to get the value of the latter member in Mojo 24.2.1 although running the same code. The value of the first member seems to return correctly.
Game Engine in Mojo?
I am trying to get into game development and wanted to use mojo. Is there a game engine in the works for Mojo as of now, or would I have to build a game from scratch once I learn the language?
SIMD or Int what should I use ?
A single integer value can be represented as both SIMD[Dtype, 1] or as Int. When should I use the first and when the former ?
vectorize changes the result of float operations
I just discovered that vectorize can change the result of floating operations. As @Maxim rightly pointed out to me, with floating point operations you can not expect (a+b)+c = a + (b+c)
```rust
from algorithm import vectorize
...
Can I contribute to Mojo Lanaugage in github?
I would like to contribute to the Mojo language, but I am not sure if it is acceptable. Could you please let me know?
Future of Literals. Are they going to be removed?
As a very interesting question for myself, we can see literal types in many of the AOT-compiled languages out there. But in Mojo, because of its goal to be more Pythonic, are we going to eventually deprecate literals? For example to have only one single 'string' type in the future?
splitting vectorize and parallelize
My first approach when optimizing a single loop is to apply vectorize. Now I wonder if it in some cases makes sense to transform the single loop into a nested loop, vectorizing the inner loop and parallelize the outer
Instead of vectorizing
```...
What's the uri?
I entered the installation code (from official): curl -s https://get.modular.com | sh -
in Windows 11 PowerShell. It asked me for the value of the Uri? What's it? The installation guide didn't mention it. Is it because I'm not using Linux Ubuntu?...
Optional string argument
Is there a simple way to create a function that takes an optional String argument with no default value (assigned to None) ? I tried the following:
...
fn my_func(my_string: Optional[String] = None)-> String:
...
fn my_func(my_string: Optional[String] = None)-> String:
...
What's the proper way to use List?
Anytime I use List, I hit issues with Reference. Looking through docs, I see that Reference is related to unsafe memory operations.
I'm looking into how to avoid variable-length collections using parameters, but I'd like to get this working first, at least. Any ideas?
```...
Transfer operator inside constructor and moveinit
I have a question regarding using the transfer operator inside constructor and moveinit as shown in this example:
https://docs.modular.com/mojo/manual/lifecycle/life#move-constructor
```...
Max Engine: Benchmark my model
When max engine is applied to my model, the result is "50 percetile latency (ns): 3410544, Mean latency (ns):3414190". I tried changing the options (ex: --mlperf-scenario ), but it did not show better performance. Is there any way to tune it?
Thanks 🙂...
Segmentation Error Occurring With Set Implementation
Hi there, I'm having a very difficult time implementing a custom datatype into the builtin set object. For somebackground I am making a an AI model from scratch to play snake and am trying to create a training environment for n number of snakes in a generation. Each update of a generation moves the snake one pixel. I have designed the snake's move operation to add a xy coordinate to a set and remove the oldest xy coordinate from the set (this is determined by a deque implementation which is unrelated). Each portion of the snakes body is stored in a
Position
object which contains the x and y position and a simd vector containing the underlying data. The data structure is Hashable
but when adding a position object, sometimes this works correctly but in some very small instances I get a segmentation error. Here is the code for the Position
data structure I made. Let me know if there is a way to hash a tuple object or any other simpler way to hash xy positions?
```Python
alias dtype = DType.int16
@value...Easier way to sum a list of integers
Hello there, I'm trying to learn Mojo by creating some small simple programs and comparing them to Python to learn key differences. I've joined an example of the last function I wrote in my code.
In this specific case, get_unbiased_run returns an integer value and the goal of this function is to sum the value of all runs. In Python, one would do a simple one liner by summing all elements of a generator. I don't know what the equivalent would be in mojo and believe this code can be optimised. I've noticed the existence of Buffers and the "sum" function from the algorithm module but not sure how I could make it work here. Any help is welcomed !
Thanks in advance 🙂...
pointer to pointer
float** ptrs[] = {
&acts->encoded,
float** ptrs[] = {
&acts->encoded,
acts->encoded
is a float* pointer, how to achive this in mojo? I have tried a lot of waysðŸ˜...Error when running modular install mojo
modular install mojo always throws the error no module named 'jupyter_client'. Mojo is installed but no jupyter kernel is available and I can't work with Mojo in a notebook. How should I fix this error? I've already tried installing the required packages to site-packages inside the python3.12 folder in venv to no avail. Here is the full error:
Traceback (most recent call last):
File "/Users/lucasgranucci/.modular/pkg/packages.modular.com_mojo/jupyter/manage_kernel.py", line 14, in <module>
from jupyter_client.kernelspec import KernelSpecManager...
Iterating over Strings containing Unicode characters?
Has anyone figured out how to do this? Maxim's code works perfectly for getting the count of printable characters in a String.
```mojo
alias simd_width_u8 = simdwidthofDType.uint8
...
Mojo + Websam
Considering compilers out there like https://emscripten.org/ that converts LLVM code to wasm. Will Mojo be a good candidate for Webasm? Afaik it uses MLIR which sits on top of LLVM but I'm not sure how the two relates. Thanks!