sora
sora
MModular
Created by lukas on 9/14/2024 in #community-showcase
WGPU-Mojo
at least get a triangle in a window
That's definitely a very nice triangle in a window, great work!
8 replies
MModular
Created by DobyDabaDu on 9/14/2024 in #questions
Copy numpy data to UnsafePointer
from memory import memcpy
from python import Python
from sys import sizeof

def main():
np = Python.import_module("numpy")

alias N = 100

a = np.arange(N, dtype=np.float32)
p = a.ctypes.data.unsafe_get_as_pointer[DType.float32]()

q = UnsafePointer[Float32].alloc(N)
memcpy(q, p, N)

l = List(unsafe_pointer=q, size=N, capacity=N)
print(l.__str__())

_ = a
from memory import memcpy
from python import Python
from sys import sizeof

def main():
np = Python.import_module("numpy")

alias N = 100

a = np.arange(N, dtype=np.float32)
p = a.ctypes.data.unsafe_get_as_pointer[DType.float32]()

q = UnsafePointer[Float32].alloc(N)
memcpy(q, p, N)

l = List(unsafe_pointer=q, size=N, capacity=N)
print(l.__str__())

_ = a
2 replies
MModular
Created by Caroline on 9/5/2024 in #community-showcase
Modverse #42 is out!
I think the latest magic only distribute nightly, and it does work with the stdlib
13 replies
MModular
Created by Nexus-6 on 9/10/2023 in #questions
Windows native SDK support
we are trying to focus first on GPU and ubuntu, which is what will help the company make money, so Windows, even though it's part of the roadmap, is not something that we'll work on immediately. On the other hand, there's interesting work we need to do in many fronts, testing, CPU debugging, GPU debugging, LSP, language interop, etc.
https://ptb.discord.com/channels/1087530497313357884/1151418340548542484/1271533276154167326
110 replies
MModular
Created by Ryulord on 8/5/2024 in #questions
MLIR Docs
The Mojo compiler "backend" consumes internal dialects such as pop, kgen, and lit, which can be considered part of the compiler, depending on your perspective. However, it does support standard dialects like index and llvm. For instance, consider the implementation of abort:
@no_inline
fn abort():
__mlir_op.`llvm.intr.trap`()
@no_inline
fn abort():
__mlir_op.`llvm.intr.trap`()
Rather than creating a built-in intrinsic (like in Rust), we implement it using inline MLIR. So I guess the claim is largely™️ true.
12 replies
MModular
Created by Ethan on 7/25/2024 in #community-showcase
Matmul.mojo
Great work! How does it compare to MAX on shapes benchmarked in this blog? https://www.modular.com/blog/the-worlds-fastest-unified-matrix-multiplication
28 replies
MModular
Created by Orwink on 7/23/2024 in #questions
Why doesn't this work for creating lists?
I'd agree that in the current stage, it's better implemented as three structs. But I don't believe this problem is fundamental: I don't think you can argue that we should expect reversed(range(n)) being slower as range(n) since the former uses the most general range structure. Also, a single iterator trait will cause the same specialisation problem if specialisation is indeed the problem, we may still need something like SizedIterable like in Swfit or c++.
13 replies
MModular
Created by Orwink on 7/23/2024 in #questions
Why doesn't this work for creating lists?
13 replies
MModular
Created by Orwink on 7/23/2024 in #questions
Why doesn't this work for creating lists?
Easy but tedious, since range maps to three _RangeSomthing structs.
13 replies
MModular
Created by Orwink on 7/23/2024 in #questions
Why doesn't this work for creating lists?
@Orwink If you are interested, maybe you could make a PR adding said overloads, since the stdlib is open source.
13 replies
MModular
Created by Orwink on 7/23/2024 in #questions
Why doesn't this work for creating lists?
Mojo is trying to recreate the everyday Python experience on a typed foundation, and there's much left to be built.
13 replies
MModular
Created by Orwink on 7/23/2024 in #questions
Why doesn't this work for creating lists?
We don't have language support to implement this constructor the right way (no trait with associated types), and no one feels compelled enought to implement the overloads for range.
13 replies
MModular
Created by bapbaj on 7/10/2024 in #questions
Returning references
I think we are indeed lacking in documentation regarding Reference etc. So, if you see any thing you want to be explained better, you could raise an issue on GH to help the team prioritize.
9 replies
MModular
Created by bapbaj on 7/10/2024 in #questions
Returning references
Ah, this proposal has already been implemented for a while now. This is design doc, so I won't say it's outdated per se, but it indeed describes an older state of the language.
9 replies
MModular
Created by bapbaj on 7/10/2024 in #questions
Returning references
It's a pointer (with lifetime tracking). For ref-count, you may use Arc
9 replies
MModular
Created by bapbaj on 7/10/2024 in #questions
Returning references
Yes. You can simply use Reference
9 replies
MModular
Created by tcorpse on 7/4/2024 in #questions
UnsafePointer & Structs
Try adding _ = x; _ = y to the end of your file
6 replies
MModular
Created by tcorpse on 7/4/2024 in #questions
UnsafePointer & Structs
I think you hit a bug of Mojo's ASAP destruction: x is deleted on the line var y = x.next("y")
6 replies
MModular
Created by Aloysius on 7/6/2024 in #community-showcase
Monte Carlo 3x Speedup
To make my position very clear: I agree with you that if we can find a good set of implicit rules, it will look way nicer. In fact, Guido himself joined this server and proposed the same thing (a: T instead of var a: T) to Chris. It's just that being a system programming language closes many doors.
23 replies
MModular
Created by Aloysius on 7/6/2024 in #community-showcase
Monte Carlo 3x Speedup
Now there is no way to define something like, for there is no way to distinguish explicit typing and variable declaration
fn f():
var a: Int
if expr:
a = 10
else:
var a = 100
use(a)
use(a)
fn f():
var a: Int
if expr:
a = 10
else:
var a = 100
use(a)
use(a)
23 replies