[all-commits] [llvm/llvm-project] 21df32: [mlir, python] Expose replaceAllUsesExcept to Pytho...

Perry Gibson via All-commits all-commits at lists.llvm.org
Tue Nov 19 16:01:20 PST 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 21df32511b558b2c1e24fe23f677fffaad4da333
      https://github.com/llvm/llvm-project/commit/21df32511b558b2c1e24fe23f677fffaad4da333
  Author: Perry Gibson <Wheest at users.noreply.github.com>
  Date:   2024-11-19 (Tue, 19 Nov 2024)

  Changed paths:
    M mlir/include/mlir-c/IR.h
    M mlir/lib/Bindings/Python/IRCore.cpp
    M mlir/lib/CAPI/IR/IR.cpp
    M mlir/test/python/ir/value.py

  Log Message:
  -----------
  [mlir,python] Expose replaceAllUsesExcept to Python bindings (#115850)

Problem originally described in [the forums
here](https://discourse.llvm.org/t/mlir-python-expose-replaceallusesexcept/83068/1).

Using the MLIR Python bindings, the method
[`replaceAllUsesWith`](https://mlir.llvm.org/doxygen/classmlir_1_1Value.html#ac56b0fdb6246bcf7fa1805ba0eb71aa2)
for `Value` is exposed, e.g.,

```python
orig_value.replace_all_uses_with(
    new_value               
)
```

However, in my use-case I am separating a block into multiple blocks, so
thus want to exclude certain Operations from having their Values
replaced (since I want them to diverge).

Within Value, we have
[`replaceAllUsesExcept`](https://mlir.llvm.org/doxygen/classmlir_1_1Value.html#a9ec8d5c61f8a6aada4062f609372cce4),
where we can pass the Operations which should be skipped.

This is not currently exposed in the Python bindings: this PR fixes
this. Adds `replace_all_uses_except`, which works with individual
Operations, and lists of Operations.



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