[dialects] Idempotent dialect extension loader#228
Conversation
Extends dialect loading mechanism to automatically handle dialect management when switching MLIR contexts. The new loader allows eager dialect registration without worrying about explicit reloading or double loading errors. Assisted-by: Claude
|
Follow-up to #225 and another dialect loading solution. Manual/caller-side dialect management has proven difficult for PyTorch backend as switching between different jitted torch models makes tracking active context difficult. Thus, a different strategy which should make loading dialects multiple times safe to perform. This way different drivers etc. can safely ensure that dialects have been loaded or reloaded just before using them. |
| context are skipped, and extensions previously loaded in a different context | ||
| are automatically re-emitted for the current one (see | ||
| ``DialectExtension.load``). Callers therefore do not need to reason about | ||
| whether a reload is required. |
There was a problem hiding this comment.
then why do we still need the reload argument?
| @classmethod | ||
| def load(cls, *args, **kwargs): | ||
| # Registers the dialect and its op classes and loads the dialect and ops into the context. | ||
| """Register and load the dialect into the current MLIR context. |
There was a problem hiding this comment.
shouldn't this really be in the MLIR bindings instead of here?
Extends dialect loading mechanism to automatically handle dialect management when switching MLIR contexts.
The new loader allows eager dialect registration without worrying about explicit reloading or double loading errors.
Assisted-by: Claude