-
Notifications
You must be signed in to change notification settings - Fork 15.4k
[mlir][python] enable registering dialects with the default Context
#72488
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -56,14 +56,24 @@ def get_include_dirs() -> Sequence[str]: | |
| # | ||
| # This facility allows downstreams to customize Context creation to their | ||
| # needs. | ||
|
|
||
|
|
||
| def get_registry(): | ||
| if not hasattr(get_registry, "__registry"): | ||
|
||
| from ._mlir import ir | ||
|
|
||
| get_registry.__registry = ir.DialectRegistry() | ||
|
|
||
| return get_registry.__registry | ||
|
|
||
|
|
||
| def _site_initialize(): | ||
| import importlib | ||
| import itertools | ||
| import logging | ||
| from ._mlir import ir | ||
|
|
||
| logger = logging.getLogger(__name__) | ||
| registry = ir.DialectRegistry() | ||
| post_init_hooks = [] | ||
| disable_multithreading = False | ||
|
|
||
|
|
@@ -84,7 +94,7 @@ def process_initializer_module(module_name): | |
| logger.debug("Initializing MLIR with module: %s", module_name) | ||
| if hasattr(m, "register_dialects"): | ||
| logger.debug("Registering dialects from initializer %r", m) | ||
| m.register_dialects(registry) | ||
| m.register_dialects(get_registry()) | ||
| if hasattr(m, "context_init_hook"): | ||
| logger.debug("Adding context init hook from %r", m) | ||
| post_init_hooks.append(m.context_init_hook) | ||
|
|
@@ -110,7 +120,7 @@ def process_initializer_module(module_name): | |
| class Context(ir._BaseContext): | ||
| def __init__(self, *args, **kwargs): | ||
| super().__init__(*args, **kwargs) | ||
| self.append_dialect_registry(registry) | ||
| self.append_dialect_registry(get_registry()) | ||
| for hook in post_init_hooks: | ||
| hook(self) | ||
| if not disable_multithreading: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.