[Mlir-commits] [mlir] [mlir] Allow dialect registry updates in a single-threaded context (PR #101119)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Mon Jul 29 20:57:33 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-mlir-core

@llvm/pr-subscribers-mlir

Author: Nikhil Kalra (nikalra)

<details>
<summary>Changes</summary>

The current `assert` in `MLIRContext::appendDialectRegistry` effectively prevents passes that leverage complex dialects (i.e. dialects with extensions) from being used in a dynamic pass pipeline. More specifically, `registry.isSubsetOf` automatically returns `false` for any dialect registry that has dialect extensions registered, even if the dialects and extensions have already been loaded into the current context.

This change relaxes the assert such that the context dialect registry can be updated inside of a dynamic pass pipeline when in single-threaded mode.

---
Full diff: https://github.com/llvm/llvm-project/pull/101119.diff


1 Files Affected:

- (modified) mlir/lib/IR/MLIRContext.cpp (+4-3) 


``````````diff
diff --git a/mlir/lib/IR/MLIRContext.cpp b/mlir/lib/IR/MLIRContext.cpp
index 12336701c9ca0..14316874e4743 100644
--- a/mlir/lib/IR/MLIRContext.cpp
+++ b/mlir/lib/IR/MLIRContext.cpp
@@ -410,9 +410,10 @@ void MLIRContext::appendDialectRegistry(const DialectRegistry &registry) {
   if (registry.isSubsetOf(impl->dialectsRegistry))
     return;
 
-  assert(impl->multiThreadedExecutionContext == 0 &&
-         "appending to the MLIRContext dialect registry while in a "
-         "multi-threaded execution context");
+  assert(!impl->threadingIsEnabled ||
+         impl->multiThreadedExecutionContext == 0 &&
+             "appending to the MLIRContext dialect registry while in a "
+             "multi-threaded execution context");
   registry.appendTo(impl->dialectsRegistry);
 
   // For the already loaded dialects, apply any possible extensions immediately.

``````````

</details>


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


More information about the Mlir-commits mailing list