jmky
jmky
MModular
Created by jmky on 3/29/2024 in #questions
Using custom bitwidth MLIR integers.
Hi If we were to create custom types that wrap around custom bitwidth integers using MLIR types and operations, does it improve performance? Theoretically, it should not right? Because if the register is 64 bits wide, it would be a waste to use only 4 bits to store a ui4 wasting the entire 60 bits. Unless, the compiler is smart enough to look at the function signature and then group many e.g UInt[4] together.
1 replies
MModular
Created by jmky on 2/16/2024 in #questions
Conditional typing of fields.
Suppose I have the following struct: (in pseudo Mojo)
struct IntWrapper[N: Int]:
@parameter
if N <= 255:
var inner: UInt8
else:
var inner: Int
struct IntWrapper[N: Int]:
@parameter
if N <= 255:
var inner: UInt8
else:
var inner: Int
For usecases where I know that it is definite that the field inner cannot hold values larger than N, then is it possible to type the fields conditionally? You can do this easily in C++, impossible to do in Rust. What about Mojo?
6 replies
MModular
Created by jmky on 11/13/2023 in #questions
A Guide on the Translation from MLIR Syntax to Mojo Syntax
The Mojo documentation states that all MLIR operations and types can be interfaced through Mojo. However, is there a guide to translate the syntaxes of MLIR dialects into Mojo syntaxes so that engineers can take more direct control on how to use MLIR operations within Mojo?
7 replies
MModular
Created by jmky on 10/17/2023 in #questions
How to trigger `cf.assert` MLIR operations?
Suppose I have
let _ = __mlir_op.`cf.assert`[msg=__mlir_attr.`"ERROR"`](false)
let _ = __mlir_op.`cf.assert`[msg=__mlir_attr.`"ERROR"`](false)
The error is that it cannot infer the return type of the MLIR operation. How do I resolve it? Thank you.
3 replies
MModular
Created by jmky on 10/7/2023 in #questions
Const generics, a runtime or compile time construct?
https://docs.modular.com/mojo/changelog.html#v0.4.0-2023-10-05 Really happy to see this development in Mojo, where StringLiteral is a const generic of type 'string', which is something not even C++ or Rust manages to do. However, I am curious if the 'instantiation' or 'specialization' of the template parameter is actually resolved during runtime or compile time. I am asking because I am waiting to be able to check the length of an input ListLiteral at compile time and do comparison with it. https://github.com/jymchng/funjo/blob/master/src/array/array.mojo#L27 #mojo
2 replies