Skip to content
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

Merged
merged 9 commits into from Jul 24, 2023
Merged

Conversation

PapyChacal
Copy link
Collaborator

@PapyChacal PapyChacal commented Jul 24, 2023

That is, the is_optional_symbol method of SymbolOpInterface, matching MLIR's isOptionalSymbol on Symbol

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 any sym_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 🙂

Implement OptionalSymbolOpInterface for user-friendliness.
Test it.
… symbol table work with the MLIR-compliant implementation.
@PapyChacal PapyChacal added the API Related to changes regarding API of constructs label Jul 24, 2023
@PapyChacal PapyChacal self-assigned this Jul 24, 2023
@codecov
Copy link

codecov bot commented Jul 24, 2023

Codecov Report

Patch coverage: 89.74% and project coverage change: -0.01 ⚠️

Comparison is base (0e5f05b) 89.64% compared to head (3f22e75) 89.64%.

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     
Impacted Files Coverage Δ
xdsl/traits.py 93.26% <71.42%> (-3.51%) ⬇️
tests/test_traits.py 99.34% <100.00%> (+0.08%) ⬆️
xdsl/dialects/builtin.py 84.73% <100.00%> (ø)
xdsl/interpreter.py 86.69% <100.00%> (+0.06%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

xdsl/traits.py Outdated
Comment on lines 256 to 265
class OptionalSymbolOpInterface(SymbolOpInterface):
"""
Helper interface specialization for an optional Symbol.
"""

@staticmethod
def is_optional_symbol(op: Operation) -> bool:
return True


Copy link
Collaborator Author

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!

xdsl/traits.py Outdated Show resolved Hide resolved
tests/test_traits.py Outdated Show resolved Hide resolved
tests/test_traits.py Outdated Show resolved Hide resolved
PapyChacal and others added 4 commits July 24, 2023 11:32
Co-authored-by: Chris Vasiladiotis <cvassiladiotis@gmail.com>
Co-authored-by: Chris Vasiladiotis <cvassiladiotis@gmail.com>
xdsl/traits.py Outdated Show resolved Hide resolved
xdsl/traits.py Show resolved Hide resolved
xdsl/traits.py Outdated Show resolved Hide resolved
xdsl/traits.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@math-fehr math-fehr left a 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!

xdsl/traits.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@math-fehr math-fehr left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Thanks!

xdsl/traits.py Show resolved Hide resolved
@PapyChacal PapyChacal merged commit b07953b into main Jul 24, 2023
10 checks passed
@PapyChacal PapyChacal deleted the emilien/symbol branch July 24, 2023 15:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
API Related to changes regarding API of constructs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants