[Mlir-commits] [mlir] [mlir][python] Propagate error diagnostics when an op couldn't be created. (PR #169499)
Benjamin Chetioui
llvmlistbot at llvm.org
Tue Nov 25 06:35:11 PST 2025
https://github.com/bchetioui created https://github.com/llvm/llvm-project/pull/169499
None
>From 1280a18d62b8c83f939ccffef92a6313dff26e33 Mon Sep 17 00:00:00 2001
From: Benjamin Chetioui <bchetioui at google.com>
Date: Tue, 25 Nov 2025 14:33:20 +0000
Subject: [PATCH] [mlir][python] Propagate error diagnostics when an op
couldn't be created.
---
mlir/lib/Bindings/Python/IRCore.cpp | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/mlir/lib/Bindings/Python/IRCore.cpp b/mlir/lib/Bindings/Python/IRCore.cpp
index b5720b7ad8b21..fd091eb8501a3 100644
--- a/mlir/lib/Bindings/Python/IRCore.cpp
+++ b/mlir/lib/Bindings/Python/IRCore.cpp
@@ -1608,9 +1608,10 @@ nb::object PyOperation::create(std::string_view name,
}
// Construct the operation.
+ PyMlirContext::ErrorCapture errors(location.getContext());
MlirOperation operation = mlirOperationCreate(&state);
if (!operation.ptr)
- throw nb::value_error("Operation creation failed");
+ throw MLIRError("Operation creation failed", errors.take());
PyOperationRef created =
PyOperation::createDetached(location->getContext(), operation);
maybeInsertOperation(created, maybeIp);
More information about the Mlir-commits
mailing list