#
5d3ae516 |
| 29-Jan-2025 |
Matthias Gehre <matthias.gehre@amd.com> |
Reapply "[mlir][python] allow DenseIntElementsAttr for index type (#118947)" (#124804)
This reapplies #118947 and adapts to nanobind.
|
Revision tags: llvmorg-21-init |
|
#
1b729c3d |
| 28-Jan-2025 |
Matthias Gehre <matthias.gehre@amd.com> |
Revert "[mlir][python] allow DenseIntElementsAttr for index type (#118947)"
This reverts commit 9dd762e8b10586e749b0ddf3542e5dccf8392395.
|
#
9dd762e8 |
| 28-Jan-2025 |
Matthias Gehre <matthias.gehre@amd.com> |
[mlir][python] allow DenseIntElementsAttr for index type (#118947)
Model the `IndexType` as `uint64_t` when converting to a python integer.
With the python bindings,
```python
DenseIntElement
[mlir][python] allow DenseIntElementsAttr for index type (#118947)
Model the `IndexType` as `uint64_t` when converting to a python integer.
With the python bindings,
```python
DenseIntElementsAttr(op.attributes["attr"])
```
used to `assert` when `attr` had `index` type like `dense<[1, 2, 3, 4]>
: vector<4xindex>`.
---------
Co-authored-by: Christopher McGirr <christopher.mcgirr@amd.com>
Co-authored-by: Tiago Trevisan Jost <tiago.trevisanjost@amd.com>
show more ...
|
Revision tags: llvmorg-19.1.7, llvmorg-19.1.6, llvmorg-19.1.5, llvmorg-19.1.4, llvmorg-19.1.3, llvmorg-19.1.2, llvmorg-19.1.1, llvmorg-19.1.0 |
|
#
334873fe |
| 11-Sep-2024 |
Amy Wang <kai.ting.wang@huawei.com> |
[MLIR][Python] Python binding support for IntegerSet attribute (#107640)
Support IntegerSet attribute python binding.
|
Revision tags: llvmorg-19.1.0-rc4, llvmorg-19.1.0-rc3, llvmorg-19.1.0-rc2, llvmorg-19.1.0-rc1, llvmorg-20-init |
|
#
c36b4248 |
| 01-Jul-2024 |
Bimo <rui.xu@intel.com> |
[MLIR][Python] add value attr for PyAffineMapAttribute (#97254)
Similar to other attributes in Binding, the `PyAffineMapAttribute`
should include a value attribute to enable users to directly retri
[MLIR][Python] add value attr for PyAffineMapAttribute (#97254)
Similar to other attributes in Binding, the `PyAffineMapAttribute`
should include a value attribute to enable users to directly retrieve
the `AffineMap` from the `AffineMapAttr`.
show more ...
|
Revision tags: llvmorg-18.1.8 |
|
#
a5985ca5 |
| 14-Jun-2024 |
klensy <klensy@users.noreply.github.com> |
[mlir][test] Fix filecheck annotation typos [2/n] (#93476)
Few more fixes
previous: https://github.com/llvm/llvm-project/pull/92897 pr
Issues from https://github.com/llvm/llvm-project/issues/93154
[mlir][test] Fix filecheck annotation typos [2/n] (#93476)
Few more fixes
previous: https://github.com/llvm/llvm-project/pull/92897 pr
Issues from https://github.com/llvm/llvm-project/issues/93154 unfixed.
---------
Co-authored-by: klensy <nightouser@gmail.com>
show more ...
|
#
fd45dcca |
| 07-Jun-2024 |
Eisuke Kawashima <e.kawaschima+github@gmail.com> |
fix(mlir/**.py): fix comparison to None (#94019)
from PEP8
(https://peps.python.org/pep-0008/#programming-recommendations):
> Comparisons to singletons like None should always be done with is or
fix(mlir/**.py): fix comparison to None (#94019)
from PEP8
(https://peps.python.org/pep-0008/#programming-recommendations):
> Comparisons to singletons like None should always be done with is or
is not, never the equality operators.
Co-authored-by: Eisuke Kawashima <e-kwsm@users.noreply.github.com>
show more ...
|
Revision tags: llvmorg-18.1.7, llvmorg-18.1.6, llvmorg-18.1.5, llvmorg-18.1.4, llvmorg-18.1.3, llvmorg-18.1.2, llvmorg-18.1.1, llvmorg-18.1.0, llvmorg-18.1.0-rc4, llvmorg-18.1.0-rc3, llvmorg-18.1.0-rc2, llvmorg-18.1.0-rc1, llvmorg-19-init, llvmorg-17.0.6, llvmorg-17.0.5, llvmorg-17.0.4, llvmorg-17.0.3, llvmorg-17.0.2, llvmorg-17.0.1, llvmorg-17.0.0, llvmorg-17.0.0-rc4 |
|
#
9f533548 |
| 31-Aug-2023 |
Ingo Müller <ingomueller@google.com> |
[mlir][python] Remove __str__ from bindings of StringAttr.
This reverts a feature introduced in commit 2a5d497494c24425e99655b85e2277dd3f15a400. The goal of that commit was to allow `StringAttr`s to
[mlir][python] Remove __str__ from bindings of StringAttr.
This reverts a feature introduced in commit 2a5d497494c24425e99655b85e2277dd3f15a400. The goal of that commit was to allow `StringAttr`s to by used transparently wherever Python `str`s are expected. But, as the tests in https://reviews.llvm.org/D159182 reveal, pybind11 doesn't do this conversion based on `__str__` automatically, unlike for the other types introduced in the commit above. At the same time, changing `__str__` breaks the symmetry with other attributes of `print(attr)` printing the assembly of the attribute, so the change probably has more disadvantages than advantages.
Reviewed By: springerm, rkayaith
Differential Revision: https://reviews.llvm.org/D159255
show more ...
|
#
2a5d4974 |
| 25-Aug-2023 |
Ingo Müller <ingomueller@google.com> |
[mlir][python] Add __{bool,float,int,str}__ to bindings of attributes.
This allows to use Python's `bool(.)`, `float(.)`, `int(.)`, and `str(.)` to convert pybound attributes to the corresponding na
[mlir][python] Add __{bool,float,int,str}__ to bindings of attributes.
This allows to use Python's `bool(.)`, `float(.)`, `int(.)`, and `str(.)` to convert pybound attributes to the corresponding native Python types. In particular, pybind11 uses these functions to automatically cast objects to the corresponding primitive types wherever they are required by pybound functions, e.g., arguments are converted to Python's `int` if the C++ signature requires a C++ `int`. With this patch, pybound attributes can by used wherever the corresponding native types are expected. New tests show-case this behavior in the constructors of `Dense*ArrayAttr`.
Note that this changes the output of Python's `str` on `StringAttr` from `"hello"` to `hello`. Arguably, this is still in line with `str`s goal of producing a readable interpretation of the value, even if it is now not unambiously a string anymore (`print(ir.Attribute.parse('"42"'))` now outputs `42`). However, this is consistent with instances of Python's `str` (`print("42")` outputs `42`), and `repr` still provides an unambigous representation if one is required.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D158974
show more ...
|
#
8dcb6722 |
| 28-Aug-2023 |
Ingo Müller <ingomueller@google.com> |
[mlir][python] Make DenseBoolArrayAttr.get work with list of bools.
This patch makes the getter function of `DenseBoolArrayAttr` work more intuitively. Until now, it was implemented with a `std::vec
[mlir][python] Make DenseBoolArrayAttr.get work with list of bools.
This patch makes the getter function of `DenseBoolArrayAttr` work more intuitively. Until now, it was implemented with a `std::vector<int>` argument, which works in the typical situation where you call the pybind function with a list of Python bools (like `[True, False]`). However, it does *not* work if the elements of the list have to be cast to Bool before (and that is the default behavior for lists of all other types). The patch thus changes the signature to `std::vector<bool>`, which helps pybind to make the function behave as expected for bools. The tests now also contain a case where such a cast is happening. This also makes the conversion of `DenseBoolArrayAttr` back to Python more intuitive: instead of converting to `0` and `1`, the elements are now converted to `False` and `True`.
Reviewed By: springerm
Differential Revision: https://reviews.llvm.org/D158973
show more ...
|
Revision tags: llvmorg-17.0.0-rc3, llvmorg-17.0.0-rc2, llvmorg-17.0.0-rc1, llvmorg-18-init |
|
#
974c1596 |
| 04-Jul-2023 |
Rahul Kayaith <rkayaith@gmail.com> |
[mlir][python] Downcast attributes in more places
Update remaining `PyAttribute`-returning APIs to return `MlirAttribute` instead, so that they go through the downcasting mechanism.
Reviewed By: ma
[mlir][python] Downcast attributes in more places
Update remaining `PyAttribute`-returning APIs to return `MlirAttribute` instead, so that they go through the downcasting mechanism.
Reviewed By: makslevental
Differential Revision: https://reviews.llvm.org/D154462
show more ...
|
#
4eee9ef9 |
| 05-Jul-2023 |
max <maksim.levental@gmail.com> |
Add SymbolRefAttr to python bindings
Differential Revision: https://reviews.llvm.org/D154541
|
Revision tags: llvmorg-16.0.6, llvmorg-16.0.5 |
|
#
9566ee28 |
| 31-May-2023 |
max <maksim.levental@gmail.com> |
[MLIR][python bindings] TypeCasters for Attributes
Differential Revision: https://reviews.llvm.org/D151840
|
#
bfb1ba75 |
| 26-May-2023 |
max <maksim.levental@gmail.com> |
[MLIR][python bindings] Add TypeCaster for returning refined types from python APIs
depends on D150839
This diff uses `MlirTypeID` to register `TypeCaster`s (i.e., `[](PyType pyType) -> DerivedTy {
[MLIR][python bindings] Add TypeCaster for returning refined types from python APIs
depends on D150839
This diff uses `MlirTypeID` to register `TypeCaster`s (i.e., `[](PyType pyType) -> DerivedTy { return pyType; }`) for all concrete types (i.e., `PyConcrete<...>`) that are then queried for (by `MlirTypeID`) and called in `struct type_caster<MlirType>::cast`. The result is that anywhere an `MlirType mlirType` is returned from a python binding, that `mlirType` is automatically cast to the correct concrete type. For example:
``` c0 = arith.ConstantOp(f32, 0.0) # CHECK: F32Type(f32) print(repr(c0.result.type))
unranked_tensor_type = UnrankedTensorType.get(f32) unranked_tensor = tensor.FromElementsOp(unranked_tensor_type, [c0]).result
# CHECK: UnrankedTensorType print(type(unranked_tensor.type).__name__) # CHECK: UnrankedTensorType(tensor<*xf32>) print(repr(unranked_tensor.type)) ```
This functionality immediately extends to typed attributes (i.e., `attr.type`).
The diff also implements similar functionality for `mlir_type_subclass`es but in a slightly different way - for such types (which have no cpp corresponding `class` or `struct`) the user must provide a type caster in python (similar to how `AttrBuilder` works) or in cpp as a `py::cpp_function`.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D150927
show more ...
|
#
f9008e63 |
| 17-May-2023 |
Tobias Hieta <tobias@hieta.se> |
[NFC][Py Reformat] Reformat python files in mlir subdir
This is an ongoing series of commits that are reformatting our Python code.
Reformatting is done with `black`.
If you end up having problems
[NFC][Py Reformat] Reformat python files in mlir subdir
This is an ongoing series of commits that are reformatting our Python code.
Reformatting is done with `black`.
If you end up having problems merging this commit because you have made changes to a python file, the best way to handle that is to run git checkout --ours <yourfile> and then reformat it with black.
If you run into any problems, post to discourse about it and we will try to help.
RFC Thread below:
https://discourse.llvm.org/t/rfc-document-and-standardize-python-code-style
Differential Revision: https://reviews.llvm.org/D150782
show more ...
|
Revision tags: llvmorg-16.0.4, llvmorg-16.0.3, llvmorg-16.0.2 |
|
#
62bf6c2e |
| 13-Apr-2023 |
Chris Jones <cjfj@deepmind.com> |
Use `bytes`, not `str`, to return C++ strings to Python.
`str` must be valid UTF-8, which is not guaranteed for C++ strings.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D14
Use `bytes`, not `str`, to return C++ strings to Python.
`str` must be valid UTF-8, which is not guaranteed for C++ strings.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D147818
show more ...
|
Revision tags: llvmorg-16.0.1, llvmorg-16.0.0, llvmorg-16.0.0-rc4, llvmorg-16.0.0-rc3, llvmorg-16.0.0-rc2 |
|
#
3ea4c501 |
| 07-Feb-2023 |
Rahul Kayaith <rkayaith@gmail.com> |
[mlir][python] Capture error diagnostics in exceptions
This updates most (all?) error-diagnostic-emitting python APIs to capture error diagnostics and include them in the raised exception's message:
[mlir][python] Capture error diagnostics in exceptions
This updates most (all?) error-diagnostic-emitting python APIs to capture error diagnostics and include them in the raised exception's message: ``` >>> Operation.parse('"arith.addi"() : () -> ()')) Traceback (most recent call last): File "<stdin>", line 1, in <module> mlir._mlir_libs.MLIRError: Unable to parse operation assembly: error: "-":1:1: 'arith.addi' op requires one result note: "-":1:1: see current operation: "arith.addi"() : () -> () ```
The diagnostic information is available on the exception for users who may want to customize the error message: ``` >>> try: ... Operation.parse('"arith.addi"() : () -> ()') ... except MLIRError as e: ... print(e.message) ... print(e.error_diagnostics) ... print(e.error_diagnostics[0].message) ... Unable to parse operation assembly [<mlir._mlir_libs._mlir.ir.DiagnosticInfo object at 0x7fed32bd6b70>] 'arith.addi' op requires one result ```
Error diagnostics captured in exceptions aren't propagated to diagnostic handlers, to avoid double-reporting of errors. The context-level `emit_error_diagnostics` option can be used to revert to the old behaviour, causing error diagnostics to be reported to handlers instead of as part of exceptions.
API changes: - `Operation.verify` now raises an exception on verification failure, instead of returning `false` - The exception raised by the following methods has been changed to `MLIRError`: - `PassManager.run` - `{Module,Operation,Type,Attribute}.parse` - `{RankedTensorType,UnrankedTensorType}.get` - `{MemRefType,UnrankedMemRefType}.get` - `VectorType.get` - `FloatAttr.get`
closes #60595
depends on D144804, D143830
Reviewed By: stellaraccident
Differential Revision: https://reviews.llvm.org/D143869
show more ...
|
Revision tags: llvmorg-16.0.0-rc1, llvmorg-17-init, llvmorg-15.0.7, llvmorg-15.0.6, llvmorg-15.0.5, llvmorg-15.0.4, llvmorg-15.0.3, working |
|
#
e3fd612e |
| 04-Oct-2022 |
Denys Shabalin <shabalin@google.com> |
[mlir] Add fully dynamic constructor to StridedLayoutAttr bindings
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D135139
|
Revision tags: llvmorg-15.0.2 |
|
#
ac2e2d65 |
| 29-Sep-2022 |
Denys Shabalin <shabalin@google.com> |
[mlir] Add Python bindings for StridedLayoutAttr
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D134869
|
Revision tags: llvmorg-15.0.1, llvmorg-15.0.0, llvmorg-15.0.0-rc3 |
|
#
619fd8c2 |
| 12-Aug-2022 |
Jeff Niu <jeff@modular.com> |
[mlir][python] Add python bindings for DenseArrayAttr
This patch adds python bindings for the dense array variants.
Fixes #56975
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.or
[mlir][python] Add python bindings for DenseArrayAttr
This patch adds python bindings for the dense array variants.
Fixes #56975
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D131801
show more ...
|
Revision tags: llvmorg-15.0.0-rc2, llvmorg-15.0.0-rc1, llvmorg-16-init |
|
#
ab9cdf09 |
| 05-Jul-2022 |
River Riddle <riddleriver@gmail.com> |
[mlir:Parser] Don't use strings for the "ugly" form of Attribute/Type syntax
This commit refactors the syntax of "ugly" attribute/type formats to not use strings for wrapping. This means that moving
[mlir:Parser] Don't use strings for the "ugly" form of Attribute/Type syntax
This commit refactors the syntax of "ugly" attribute/type formats to not use strings for wrapping. This means that moving forward attirbutes and type formats will always need to be in some recognizable form, i.e. if they use incompatible characters they will need to manually wrap those in a string, the framework will no longer do it automatically.
This has the benefit of greatly simplifying how parsing attributes/types work, given that we currently rely on some extremely complicated nested parser logic which is quite problematic for a myriad of reasons; unecessary complexity(we create a nested source manager/lexer/etc.), diagnostic locations can be off/wrong given string escaping, etc.
Differential Revision: https://reviews.llvm.org/D118505
show more ...
|
Revision tags: llvmorg-14.0.6, llvmorg-14.0.5, llvmorg-14.0.4, llvmorg-14.0.3, llvmorg-14.0.2, llvmorg-14.0.1, llvmorg-14.0.0, llvmorg-14.0.0-rc4 |
|
#
5c3861b2 |
| 11-Mar-2022 |
Yun Long <longy@google.com> |
[MLIR][python binding] Add OpaqueAttribute to python binding.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D120847
|
Revision tags: llvmorg-14.0.0-rc3, llvmorg-14.0.0-rc2 |
|
#
e9db306d |
| 24-Feb-2022 |
rkayaith <rkayaith@gmail.com> |
[mlir][python] Support more types in IntegerAttr.value
Previously only accessing values for `index` and signless int types would work; signed and unsigned ints would hit an assert in `IntegerAttr::g
[mlir][python] Support more types in IntegerAttr.value
Previously only accessing values for `index` and signless int types would work; signed and unsigned ints would hit an assert in `IntegerAttr::getInt`. This exposes `IntegerAttr::get{S,U}Int` to the C API and calls the appropriate function from the python bindings.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D120194
show more ...
|
Revision tags: llvmorg-14.0.0-rc1, llvmorg-15-init |
|
#
308d8b8c |
| 21-Jan-2022 |
Rahul Kayaith <rahul@untether.ai> |
[mlir][python] 8b/16b DenseIntElements access
This extends dense attribute element access to support 8b and 16b ints. Also extends the corresponding parts of the C api.
Reviewed By: ftynse
Differe
[mlir][python] 8b/16b DenseIntElements access
This extends dense attribute element access to support 8b and 16b ints. Also extends the corresponding parts of the C api.
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D117731
show more ...
|
Revision tags: llvmorg-13.0.1, llvmorg-13.0.1-rc3, llvmorg-13.0.1-rc2, llvmorg-13.0.1-rc1 |
|
#
f78fe0b7 |
| 02-Nov-2021 |
rkayaith <rkayaith@gmail.com> |
[mlir][python] Make Operation and Value hashable
This allows operations and values to be used as dict keys
Reviewed By: ftynse
Differential Revision: https://reviews.llvm.org/D112669
|