[Mlir-commits] [mlir] [mlir, python] Expose replaceAllUsesExcept to Python bindings (PR #115850)
Oleksandr Alex Zinenko
llvmlistbot at llvm.org
Tue Nov 12 09:49:46 PST 2024
================
@@ -3718,6 +3724,29 @@ void mlir::python::populateIRCore(py::module &m) {
mlirValueReplaceAllUsesOfWith(self.get(), with.get());
},
kValueReplaceAllUsesWithDocstring)
+ .def(
+ "replace_all_uses_except",
+ [](MlirValue self, MlirValue with, PyOperation &exception) {
+ MlirOperation exceptedUser = exception.get();
+ mlirValueReplaceAllUsesExceptWithSingle(self, with, exceptedUser);
+ },
+ py::arg("with"), py::arg("exceptions"),
+ kValueReplaceAllUsesExceptDocstring)
+ .def(
+ "replace_all_uses_except",
+ [](MlirValue self, MlirValue with, py::list exceptions) {
+ // Convert Python list to a SmallVector of MlirOperations
+ llvm::SmallVector<MlirOperation, 4> exceptionOps;
----------------
ftynse wrote:
```suggestion
llvm::SmallVector<MlirOperation> exceptionOps;
```
Don't specify the number of stack elements unless there is a strong reason to pick one.
https://github.com/llvm/llvm-project/pull/115850
More information about the Mlir-commits
mailing list