[transform_ext] Useful Python-defined TransformOpInterface ops#68
[transform_ext] Useful Python-defined TransformOpInterface ops#68
Conversation
adam-smnk
left a comment
There was a problem hiding this comment.
Great utility 👍
It'll be particularly helpful with support transform like IR traversal etc.
And a good staging ground toward testing new ideas before upstreaming.
| from mlir.dialects.transform import DiagnosedSilenceableFailure | ||
|
|
||
|
|
||
| def register_and_load(**kwargs): |
There was a problem hiding this comment.
Nothing to do with PR itself but an random idea.
I wonder if this could be done automatically on module import.
There was a problem hiding this comment.
The upstream bindings do something like that, though they only register the dialect and operation classes. Because we use DynamicDialects under the hood, for the Python-defined dialects the _load_ing of the dialect needs to happen when we are under an ir.Context. Generally you import the module at file scope and hence not when there's an active context.
I think there might be a way to make this a bit more magic, but currently we don't have support. Will think about how to make this possible though!
There was a problem hiding this comment.
Right, missed the need for ir.Context to be active.
Then an explicit call might be better.
Perhaps, we could just provide a lighthouse context decorator that performs more initialization steps.
| __all__ = ["register_and_load", "transform_ext"] | ||
|
|
||
|
|
||
| def register_and_load(**kwargs): |
There was a problem hiding this comment.
Can you just us from dialects import register_and_load?
There was a problem hiding this comment.
Doing from lighthouse.dialects import register_and_load in other files indeed works.
Personally I prefer from lighthouse import dialects as lh_dialects so that when it's time to call lh_dialects.register_and_load() I have a clue about what's being registered and loaded.
No description provided.