[all-commits] [llvm/llvm-project] d898ff: [mlir, python] Fix case when `FuncOp.arg_attrs` is ...
Perry Gibson via All-commits
all-commits at lists.llvm.org
Mon Dec 2 08:56:14 PST 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d898ff650ae09e3ef942592aee2e87627f45d7c6
https://github.com/llvm/llvm-project/commit/d898ff650ae09e3ef942592aee2e87627f45d7c6
Author: Perry Gibson <Wheest at users.noreply.github.com>
Date: 2024-12-02 (Mon, 02 Dec 2024)
Changed paths:
M mlir/python/mlir/dialects/func.py
M mlir/test/python/dialects/func.py
Log Message:
-----------
[mlir,python] Fix case when `FuncOp.arg_attrs` is not set (#117188)
FuncOps can have `arg_attrs`, an array of dictionary attributes
associated with their arguments.
E.g.,
```mlir
func.func @main(%arg0: tensor<8xf32> {test.attr_name = "value"}, %arg1: tensor<8x16xf32>)
```
These are exposed via the MLIR Python bindings with
`my_funcop.arg_attrs`.
In this case, it would return `[{test.attr_name = "value"}, {}]`, i.e.,
`%arg1` has an empty `DictAttr`.
However, if I try and access this property from a FuncOp with an empty
`arg_attrs`, e.g.,
```mlir
func.func @main(%arg0: tensor<8xf32>, %arg1: tensor<8x16xf32>)
```
This raises the error:
```python
return ArrayAttr(self.attributes[ARGUMENT_ATTRIBUTE_NAME])
~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
KeyError: 'attempt to access a non-existent attribute'
```
This PR fixes this by returning the expected `[{}, {}]`.
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list