Based on PyAttribute and PyConcreteAttribute classes, this patch implements the bindings of Float Attribute, Integer Attribute and Bool Attribute subclasses.
This patch also defines the mlirFloatAttrDoubleGetChecked C API which is bound with the FloatAttr.get python method.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Thanks!
mlir/include/mlir-c/StandardAttributes.h | ||
---|---|---|
97 | Can you change this to something like: "if the type is not valid for a construction of a FloatAttr, returns a null MlirAttribute." | |
mlir/lib/Bindings/Python/IRModules.cpp | ||
753 | It is common enough that I feel we would benefit from a get_f32 and get_f64 that do not take a type and do not fail. | |
754 | Maybe drop the _typed suffix? | |
789 | Ditto on just get | |
815 | Change the c++ type to bool. (Aside from being more correct, that will trigger important conversion rules on the python side for "truthy" value). | |
mlir/test/Bindings/Python/ir_attributes.py | ||
143 | Test with True, not 1 |
mlir/lib/Bindings/Python/IRModules.cpp | ||
---|---|---|
753 | I'd like to confirm that if we give the get_f32 and get_f64 methods, then what about the f16 and bf16 float type, and do we still need to give the default get method (It seems that get_f32, get_f64, get_f16, get_bf16 can cover all the usage)? |
- Modify the comment for mlirFloatAttrDoubleGetChecked.
- Drop the _typed suffix for FloatAttr and IntegerAttr get methods.
- Change the parameter type of BoolAttr.get method to bool.
- Add get_f32 and get_f64 methods to FloatAttr.
Can you change this to something like: "if the type is not valid for a construction of a FloatAttr, returns a null MlirAttribute."