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
Implement is_optional_symbol for MLIR compliance. #1330
Conversation
Implement OptionalSymbolOpInterface for user-friendliness. Test it.
… symbol table work with the MLIR-compliant implementation.
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## main #1330 +/- ##
==========================================
- Coverage 89.64% 89.64% -0.01%
==========================================
Files 191 191
Lines 24868 24898 +30
Branches 3750 3756 +6
==========================================
+ Hits 22294 22320 +26
- Misses 1982 1984 +2
- Partials 592 594 +2
☔ View full report in Codecov by Sentry. |
xdsl/traits.py
Outdated
class OptionalSymbolOpInterface(SymbolOpInterface): | ||
""" | ||
Helper interface specialization for an optional Symbol. | ||
""" | ||
|
||
@staticmethod | ||
def is_optional_symbol(op: Operation) -> bool: | ||
return True | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Digging in MLIR's sources, that's the only specialization I saw, and a few times, hence exposing it directly as is in the xDSL practical/firendly mindset!
Co-authored-by: Chris Vasiladiotis <cvassiladiotis@gmail.com>
Co-authored-by: Chris Vasiladiotis <cvassiladiotis@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! I put some comments, but otherwise that's good to me!
Co-authored-by: Fehr Mathieu <mathieu.fehr@gmail.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice! Thanks!
That is, the
is_optional_symbol
method ofSymbolOpInterface
, matching MLIR'sisOptionalSymbol
onSymbol
Implement OptionalSymbolOpInterface for user-friendliness. Test it.
Our current implementation of SymbolOps is not compliant with MLIR's, which allows optionally symbol operations 🙃
The most famous example being
builtin.module
, which can be anonymous as often for the top-level module, thus not containing anysym_name
attribute.I also take the opprtunity to make
builtin.module
an optional symbol operation. With this MLIR-compliant implementation, the only impact is to make the interpreter work with this compliance 🙂