[Mlir-commits] [mlir] [mlir, python] Expose replaceAllUsesExcept to Python bindings (PR #115850)

Perry Gibson llvmlistbot at llvm.org
Tue Nov 12 12:54:22 PST 2024


Wheest wrote:

Cheers both!  I'm happy to get it merged now if there are no further comments.

I've implemented @ftynse's suggestions.

For @makslevental, I added the PybindAdaptor, stuff, worth it I reckon.

Only things to point out are:

1. If you note `d9c3cd7`, I had to revert `MlirOperation exception` back to `PyOperation &exception`, as this was not compatible with the ADL:

Calling `value.replace_all_uses_except(value2, [op1, op2])` raised the error

```
# | TypeError: Expected an MLIR object (got [<mlir._mlir_libs._mlir.ir.Operation object at 0x71b9f1341270>, <mlir._mlir_libs._mlir.ir.Operation object at 0x71b9f1342730>]).
```

2. I fixed the first test `testValueReplaceAllUsesWithExcept`

```diff
- value.replace_all_uses_except(value2, [op1])
+ value.replace_all_uses_except(value2, op1)
```

As you can see, before I was testing passing a list of an Operation, which doesn't cover the behaviour I wanted to check.

Btw, thanks for running https://github.com/makslevental/mlir-wheels/, it has been a boon to my hacking!

https://github.com/llvm/llvm-project/pull/115850


More information about the Mlir-commits mailing list