Compile time `U8`
@Modular Staff I'm writing to write a struct
U8
that kind of models after Int
.
Here is my impl:
It does check for the range (0-255) but not shown because the code snippet is sufficient to showcase the error I faced which is:
15 Replies
I think this error happens because
1. There is certain 'translation' between MLIR operations and Mojo syntax with 'generic' type parameters
[...]
and function calls (...)
so it is not clear how the _type
type parameter appears, probably is to avoid collision with Python's input type
function.
2. In the MLIR's docs, it says the type of $value
can be an index
or an integer
, yet it doesn't say where can one get an attr-dict
of type integer
.'index' Dialect - MLIR
Multi-Level IR Compiler Framework
Doesn't work either
any hlep?
@JIMC don't ping modular staff please
There are a lot of questions, and we'll get to this when we can, but pinging the entire staff is not going to accelerate that.
Oh, I just need to know how do I get the
integer
type in the index
dialect within Mojo. I can't seem to convert index
to ui8
within Mojo.Hi @JIMC that code runs for me without an error, can you please provide the full code that's causing the problem, if you don't have enough space here can you make a gist?
Thank you for your reply, I am actually in the office now and has no access to the full codes. Would you mind, if it is convenient for you, to share your codes here, which had worked for you? So I can study it on the go, before I regain access to my codes tonight. 😄
Congrats @jmky, you just advanced to level 2!
Exactly what you posted in that first code block compiled for me in mojo SDK version
0.2.1
Hi, good day to all.
Snippet:
Error:
Questions
1. Seems like Mojo is unable to 'cast' a value at compile time to fit into a self-defined
UInt8
struct.
2. How to make it work?Congrats @JIMC, you just advanced to level 3!
array3.mojo:13:64: note: failed to fold operation index.castu(4 : index)
value: mlir_op.
index.castu
[_type: mlir_type.ui8](value_as_index)
i dont unds why this fails
That looks like a compiler bug! Could you file an issue for that plz?
@Chris Lattner Thank you for your reply, I have created an issue here: https://github.com/modularml/mojo/issues/776
GitHub
[BUG]: Unable to convert a MLIR type to another MLIR type at compil...
Bug description I am attempting to create my own UInt8 following the tutorial on Mojo's documentation on the creation of a new boolean. Below is my implementation: @register_passable('trivi...
Thanks @JIMC much appreciated 🙂