Stole
MModular
•Created by Pièrre on 12/25/2023 in #questions
any Windows + Vscode (using WSL2 as middle-man) guide?
Yep, I've been using it just like that for a while now and it's been working great
4 replies
MModular
•Created by Vijay Yadav on 12/19/2023 in #questions
How to convert string to float value?
There is also the option of using
external_call
and the strtof
C function, like so
Although of course the obligatory "current FFI is not stable and expect it to change" disclosure must be included12 replies
MModular
•Created by chebu_pizza on 12/13/2023 in #questions
Is it possible to push mojo code on GitHub?
Best thing to do is probably just to get them into the language itself so people naturally start using it more and pushing more Mojo files, not to tell them to create arbitrary files. It's true, we don't want to game the system
16 replies
MModular
•Created by isack on 12/14/2023 in #questions
Can anyone help me to solve this error.
I think you can go ahead and still make an issue, but make it instead about a better error in this case. Because something like:
should probably produce an error less cryptic
10 replies
MModular
•Created by isack on 12/14/2023 in #questions
Can anyone help me to solve this error.
I guess it's true the compiler should emit a better error than this, but changing that last
Float64
to something like 0.5
(I don't know the actual base GFLOPS that Python runs this at) works10 replies
MModular
•Created by isack on 12/14/2023 in #questions
Can anyone help me to solve this error.
The reason is because you're passing the type
Float64
into bench
at the end, when it really expects something of the type Float64
, like 1.0
or a variable10 replies
MModular
•Created by isack on 12/14/2023 in #questions
Can anyone help me to solve this error.
Wait, I completely missed something
10 replies
MModular
•Created by isack on 12/14/2023 in #questions
Can anyone help me to solve this error.
Wow, this is a bad bug. Looks like an actual language one, there's something bad happening under the hood. So far I can't see a way to get around it, would be good to create an issue on the Github https://github.com/modularml/mojo/issues. I took a look and didn't see anything similar to this previously reported.
10 replies
MModular
•Created by isack on 12/14/2023 in #questions
Can anyone help me to solve this error.
It looks like a double free, you're calling
A.data.free()
and etc. for all the matrices after the benchmark is run, but when they get destructed, each __del__
gets called, freeing the pointers again. You can keep the matrices alive a different way, like I just changed those A.data.free()
calls to _ = A.rows
or quite literally anything that uses the matrices, or remove the free call in __del__
. I think the first option is "better" practice for now.
This is what I ran, and it appears to work as expected.
10 replies
MModular
•Created by chebu_pizza on 12/13/2023 in #questions
Is it possible to push mojo code on GitHub?
Yeah, the comment here https://github.com/github-linguist/linguist/pull/6400#issuecomment-1716773725 suggests they're separate for purposes of Linguist recognition, but maybe once both meet the requirements something different could happen. Unfortunately, I don't know too many details
16 replies
MModular
•Created by chebu_pizza on 12/13/2023 in #questions
Is it possible to push mojo code on GitHub?
Yes, you can, and please do. There's a goal of 2k unique Mojo files on Github, and then they'll add Mojo as a recognized language
16 replies
MModular
•Created by JIMC on 12/4/2023 in #questions
Trying to do compile time checking with 'const' type arguments.
It seems to produce the same errors on the most recent, 0.6.0 (d55c0025)
11 replies
MModular
•Created by JIMC on 12/4/2023 in #questions
Trying to do compile time checking with 'const' type arguments.
As the error message suggests, it does look like due to the definition of
ListLiteral
that Secret
or whatever is being carried has to be register passable, so I went ahead and changed the Secret
struct. This might be wildly contrary to what you initially wanted, but it does look like in order to use a heterogenous collection, the types have to be register passable: including ListLiteral
and Tuple
.
You can see (along with my great variable naming here) that the following code does not compile:
However, if you remove one of the first my_secret
s and adjust the names appropriately, it will compile. So I think this is closer to fulfilling your goal; correct me if this is wrong though.
Side note: It is strange that in the last .get
call, you can change the EC and MEC type params in the Secret[Int, ...]
part to be basically anything, and the compiler doesn't complain. However, if you change the initial type from Int
to something else, it complains. I guess this might make sense considering the result type of the pesky MLIR operation kgen.pack.get
cares about the types and might handle the value parameters differently, but it's still quite interesting.11 replies
MModular
•Created by b4rdarian on 10/24/2023 in #questions
Confusion with owned integers
I think the compiler's behavior on this isn't fully fleshed out, or blocked on traits, and that's why it worked with
String
when it ideally shouldn't32 replies
MModular
•Created by b4rdarian on 10/24/2023 in #questions
Confusion with owned integers
Even though you do have that object under y, x is now invalid
32 replies
MModular
•Created by b4rdarian on 10/24/2023 in #questions
Confusion with owned integers
You can't use the original one declared because that was consumed by your function call, albeit it did pass ownership back when you assigned it to y in your Int example
32 replies
MModular
•Created by b4rdarian on 10/24/2023 in #questions
Confusion with owned integers
Yeah, this is correct
32 replies
MModular
•Created by seb on 10/22/2023 in #questions
List of memory-only structs
Yeah,
Pointer
s to any type that isn't a "simple" struct (not register_passable
) don't work. I wrote a more detailed explanation here: https://discord.com/channels/1087530497313357884/1098713601386233997/1164304975816556655, albeit for a slightly different use case. The main point is the same, if you want such a thing you're essentially just going to be managing the memory yourself. Here, you can mark Neuron
with @register_passable
, then maybe add a copy
method that then copies the struct's Tensor
over so we don't duplicate pointers, and other similar operations.8 replies
MModular
•Created by Sammi Turner on 10/4/2023 in #questions
Refactoring from DynamicVector to a different data structure?
DynamicVector
's really for containers that change size a lot. Mojo has a Tuple
type which has similar functionality to Python's tuple
, and you can see it here: https://docs.modular.com/mojo/stdlib/builtin/tuple.html. However, I think that StaticTuple
(https://docs.modular.com/mojo/stdlib/utils/static_tuple.html) actually could be better suited here, since it's for containers whose sizes don't change, and with homogenous types (Tuple
can handle different types, which we don't need, and makes it a little more annoying to access elements).
Something like this is likely what you're looking for.
3 replies
MModular
•Created by Jake Brooks on 10/3/2023 in #questions
Possible to get a meaningful time value?
Whoops, sorry I didn't see this till now. sa-code's got it, though 😉
14 replies