[all-commits] [llvm/llvm-project] ca23c9: [mlir][python] Create all missing attribute builders.
Ingo Müller via All-commits
all-commits at lists.llvm.org
Wed Sep 6 00:09:40 PDT 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: ca23c933bda9bdb4ef4cc8204834167f5f031401
https://github.com/llvm/llvm-project/commit/ca23c933bda9bdb4ef4cc8204834167f5f031401
Author: Ingo Müller <ingomueller at google.com>
Date: 2023-09-06 (Wed, 06 Sep 2023)
Changed paths:
M mlir/include/mlir/IR/CommonAttrConstraints.td
M mlir/python/mlir/ir.py
M mlir/test/python/dialects/python_test.py
M mlir/test/python/python_test_ops.td
Log Message:
-----------
[mlir][python] Create all missing attribute builders.
This patch adds attribute builders for all buildable attributes from the
builtin dialect that did not previously have any. These builders can be
used to construct attributes of a particular type identified by a string
from a Python argument without knowing the details of how to pass that
Python argument to the attribute constructor. This is used, for example,
in the generated code of the Python bindings of ops.
The list of "all" attributes was produced with:
(
grep -h "ods_ir.AttrBuilder.get" $(find ../build/ -name "*_ops_gen.py") \
| cut -f2 -d"'"
git grep -ho "^def [a-zA-Z0-9_]*" -- include/mlir/IR/CommonAttrConstraints.td \
| cut -f2 -d" "
) | sort -u
Then, I only retained those that had an occurence in
`mlir/include/mlir/IR`. In particular, this drops many dialect-specific
attributes; registering those builders is something that those dialects
should do. Finally, I removed those attrbiutes that had a match in
`mlir/python/mlir/ir.py` already and implemented the remaining ones. The
only ones that still miss a builder now are the following:
* Represent more than one possible attribute type:
- `Any.*Attr` (9x)
- `IntNonNegative`
- `IntPositive`
- `IsNullAttr`
- `ElementsAttr`
* I am not sure what "constant attributes" are:
- `ConstBoolAttrFalse`
- `ConstBoolAttrTrue`
- `ConstUnitAttr`
* `Location` not exposed by Python bindings:
- `LocationArrayAttr`
- `LocationAttr`
* `get` function not implemented in Python bindings:
- `StringElementsAttr`
This patch also fixes a compilation problem with
`I64SmallVectorArrayAttr`.
Reviewed By: makslevental, rkayaith
Differential Revision: https://reviews.llvm.org/D159403
More information about the All-commits
mailing list