Stijn
Stijn
MModular
Created by Jack Clayton on 5/10/2024 in #community-showcase
Basalt: ML Framework
There are definitely some influences from other frameworks, but it's also very much tailored to whatever Mojo allows. You'll should recognize stuff from pytorch, tinygrad, mlx. Those are probably the ones that are most looked at
26 replies
MModular
Created by NKspartan on 5/14/2024 in #questions
Will mojo support JIT compilation?
Could you share an example?
25 replies
MModular
Created by ivellapillil on 5/15/2024 in #community-showcase
Online book on Mojo
🔥
34 replies
MModular
Created by NKspartan on 5/14/2024 in #questions
Will mojo support JIT compilation?
+1
25 replies
MModular
Created by Stijn on 4/1/2024 in #questions
Parameters style guide
Sorry for the delay. Filed the issue here https://github.com/modularml/mojo/issues/2557
11 replies
MModular
Created by Stijn on 4/1/2024 in #questions
Parameters style guide
Thanks Joe
11 replies
MModular
Created by Kyle Hassold on 10/28/2023 in #questions
Fastest Matrix Multiplication
@jon-chuang Very impressive result. Thanks for sharing
20 replies
MModular
Created by seb on 10/22/2023 in #questions
List of memory-only structs
Just found this: https://docs.modular.com/mojo/stdlib/builtin/builtin_list.html#variadiclistmem. Just handling pointers without having to deal with register_passable("trivial")
8 replies
MModular
Created by seb on 10/22/2023 in #questions
List of memory-only structs
@seb This looks like a working workaround. Will have a better look at it later: cfr. @rd4com : new small tutorial: 🤹 making lists of structs with magic operators (until lifetimes) https://github.com/rd4com/mojo-learning/blob/main/tutorials/lists-of-structs-magic-operators-pre-lifetimes.md
8 replies
MModular
Created by seb on 10/22/2023 in #questions
List of memory-only structs
I'm here now (trying to work around it)
struct MyClass[dtype: DType]:
var tensor: Tensor[dtype]
fn init(inout self, tensor: Tensor[dtype]):
self.tensor = tensor


fn main():
alias dtype = DType.float32
alias nelts: Int = simdwidthof[dtype]()

let tensor: Tensor[dtype] = rand[dtype](2, 5)
var myelement = MyClass[dtype](tensor)


let xPtr = Pointer[MyClass[dtype]].address_of(myelement) # get address memory of x
print(xPtr.as_index()) # print address memory of x

var vec = DynamicVector[Pointer[MyClass[dtype]]]()
vec.push_back(xPtr)
for i in range(vec.size):
print(vec[i].as_index())

let x : MyClass[dtype] = xPtr.load()
print(x.tensor)
struct MyClass[dtype: DType]:
var tensor: Tensor[dtype]
fn init(inout self, tensor: Tensor[dtype]):
self.tensor = tensor


fn main():
alias dtype = DType.float32
alias nelts: Int = simdwidthof[dtype]()

let tensor: Tensor[dtype] = rand[dtype](2, 5)
var myelement = MyClass[dtype](tensor)


let xPtr = Pointer[MyClass[dtype]].address_of(myelement) # get address memory of x
print(xPtr.as_index()) # print address memory of x

var vec = DynamicVector[Pointer[MyClass[dtype]]]()
vec.push_back(xPtr)
for i in range(vec.size):
print(vec[i].as_index())

let x : MyClass[dtype] = xPtr.load()
print(x.tensor)
But you can't do the pointer.load() as well. I know you could probably do it with Low level IR. But i would rather not go down that rabithole
8 replies
MModular
Created by seb on 10/22/2023 in #questions
List of memory-only structs
@Stole @seb Currently running into the same error. I tried to store the pointers of your class in a DynamicVector and that works. But when you are trying to dereference again it produces the same error. Any of you, or anyone else, that have found a workaround while we are waiting for traits?
8 replies
MModular
Created by Stijn on 10/22/2023 in #questions
redefinition of symbol named '$< ... >'
6 replies
MModular
Created by Stijn on 10/22/2023 in #questions
redefinition of symbol named '$< ... >'
Yeah i might do that
6 replies
MModular
Created by Stijn on 10/2/2023 in #questions
cannot be copied into its destination
Solved it:
@always_inline
fn __copyinit__(inout self, other: Matrix[dtype, n_rows, n_cols]):
self.data = DTypePointer[dtype].alloc(n_rows * n_cols)
for y in range(n_rows):
for x in range(n_cols):
self.data.simd_store[1](y * n_cols + x, other.data.simd_load[1](y * n_cols + x))
self.rows = other.rows
self.cols = other.cols
@always_inline
fn __copyinit__(inout self, other: Matrix[dtype, n_rows, n_cols]):
self.data = DTypePointer[dtype].alloc(n_rows * n_cols)
for y in range(n_rows):
for x in range(n_cols):
self.data.simd_store[1](y * n_cols + x, other.data.simd_load[1](y * n_cols + x))
self.rows = other.rows
self.cols = other.cols
4 replies
MModular
Created by Stijn on 10/2/2023 in #questions
cannot be copied into its destination
As soon as I start using the copies I'm getting:
free(): double free detected in tcache 2
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 main.mojo
#0 0x00005602b1ba3797 (mojo+0x5bc797)
#1 0x00005602b1ba136e (mojo+0x5ba36e)
#2 0x00005602b1ba3e6f (mojo+0x5bce6f)
#3 0x00007f7086242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f7086296a7c __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
#5 0x00007f7086296a7c __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
#6 0x00007f7086296a7c pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
#7 0x00007f7086242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f70862287f3 abort ./stdlib/./stdlib/abort.c:81:7
#9 0x00007f70862896f6 __libc_message ./libio/../sysdeps/posix/libc_fatal.c:155:5
#10 0x00007f70862a0d7c ./malloc/./malloc/malloc.c:5668:3
#11 0x00007f70862a312b _int_free ./malloc/./malloc/malloc.c:4687:2
#12 0x00007f70862a54d3 __libc_free ./malloc/./malloc/malloc.c:3394:3
#13 0x00007f6fc400150f
Aborted
free(): double free detected in tcache 2
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 main.mojo
#0 0x00005602b1ba3797 (mojo+0x5bc797)
#1 0x00005602b1ba136e (mojo+0x5ba36e)
#2 0x00005602b1ba3e6f (mojo+0x5bce6f)
#3 0x00007f7086242520 (/lib/x86_64-linux-gnu/libc.so.6+0x42520)
#4 0x00007f7086296a7c __pthread_kill_implementation ./nptl/./nptl/pthread_kill.c:44:76
#5 0x00007f7086296a7c __pthread_kill_internal ./nptl/./nptl/pthread_kill.c:78:10
#6 0x00007f7086296a7c pthread_kill ./nptl/./nptl/pthread_kill.c:89:10
#7 0x00007f7086242476 gsignal ./signal/../sysdeps/posix/raise.c:27:6
#8 0x00007f70862287f3 abort ./stdlib/./stdlib/abort.c:81:7
#9 0x00007f70862896f6 __libc_message ./libio/../sysdeps/posix/libc_fatal.c:155:5
#10 0x00007f70862a0d7c ./malloc/./malloc/malloc.c:5668:3
#11 0x00007f70862a312b _int_free ./malloc/./malloc/malloc.c:4687:2
#12 0x00007f70862a54d3 __libc_free ./malloc/./malloc/malloc.c:3394:3
#13 0x00007f6fc400150f
Aborted
Any idea?
4 replies