-
In Mojo's tutorial, it is shown that Mojo data types can be easily constructed with MLIR data types: let a : __mlir_type.i1 = __mlir_op.`index.bool.constant`[value : __mlir_attr.`false`]()
let b = Bool(a) However, this conversion doesn't work in another direction: let x : Bool = True
let y : __mlir_type.i1 = x # errors Similar examples can also be found in the doc, like |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can't add methods to MLIR types, and Python doesn't have a way of doing conversions like this. C++ has a way to do this with the "operator T()" sorts of methods, which we could add, but we haven't explored that part of the design space yet. For now, the best way to go is to add a "to_i1()" sort of method to a type if you can, or define a |
Beta Was this translation helpful? Give feedback.
You can't add methods to MLIR types, and Python doesn't have a way of doing conversions like this. C++ has a way to do this with the "operator T()" sorts of methods, which we could add, but we haven't explored that part of the design space yet.
For now, the best way to go is to add a "to_i1()" sort of method to a type if you can, or define a
to_i1(x)
global function