[all-commits] [llvm/llvm-project] 98195e: [MLIR][Python] Make Python-defined dialect loading...
Twice via All-commits
all-commits at lists.llvm.org
Fri Jul 24 04:34:46 PDT 2026
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 98195e0458dd5ec037785a6f861c6402bec778b3
https://github.com/llvm/llvm-project/commit/98195e0458dd5ec037785a6f861c6402bec778b3
Author: Twice <twice at apache.org>
Date: 2026-07-24 (Fri, 24 Jul 2026)
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/python/mlir/dialects/ext.py
M mlir/test/python/dialects/ext.py
M mlir/test/python/dialects/transform_op_interface.py
M mlir/test/python/dialects/transform_pattern_descriptor_op_interface.py
Log Message:
-----------
[MLIR][Python] Make Python-defined dialect loading context-aware (#210501)
Python-defined dialect loading currently relies on
`Dialect._mlir_module` to infer whether a dialect has already been
loaded. This state belongs to the Python dialect class rather than an
MLIR context.
Consequently, loading the same dialect after switching contexts requires
`reload=True`, while reloading it in a context where it is already
present can hit the operation registration assertion reported in
#210053.
This patch adds `mlirContextGetLoadedDialect` (following
https://github.com/llvm/lighthouse/pull/228#discussion_r3589792891) to
the C API and exposes it as `Context.is_dialect_loaded`.
`Dialect.load()` now queries the active context:
- loading a dialect more than once in the same context raises a
`RuntimeError`;
- loading the same Python-defined dialect in another context succeeds
without a `reload` flag.
The `reload` parameter is semantically wrong (mentioned in
https://github.com/llvm/lighthouse/pull/228#discussion_r3586672116) thus
removed from the API as a small breaking change. Usually, users who are
using `reload` can just remove it and everything will work fine.
Fixes #210053.
Assisted by GPT 5.6 Sol (for writing test cases).
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