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

core: always print unregistered ops #3303

Merged
merged 4 commits into from
Oct 18, 2024
Merged

core: always print unregistered ops #3303

merged 4 commits into from
Oct 18, 2024

Conversation

alexarice
Copy link
Collaborator

scf.for prints it's blocks without terminators if there are no iter_args. Unfortunately the check for whether an operation is a terminator returns true by default for unregistered operations (presumably so that they don't break verification), and so they don't get printed.

This change should make it so that these ops always get printed.

@alexarice alexarice added bug Something isn't working core xDSL core (ir, textual format, ...) labels Oct 15, 2024
@alexarice alexarice self-assigned this Oct 15, 2024
@alexarice
Copy link
Collaborator Author

@AntonLydike feel free to add your example as a test case

@alexarice
Copy link
Collaborator Author

If not I can make one

Copy link
Member

@superlopuh superlopuh left a comment

Choose a reason for hiding this comment

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

Code change looks good and a simple "unregistered_op"() : () -> () should work as a test, right?

@alexarice
Copy link
Collaborator Author

I added a small test, but in the process found that the implicit terminator stuff in scf.for doesn't roundtrip. It seems to me that the cause is the ensure_terminator function, which from my understanding of the docstring should add a terminator if it is not present, but it instead just throws a verify error

Copy link

codecov bot commented Oct 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.02%. Comparing base (a7d8ebe) to head (299dc70).
Report is 15 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3303   +/-   ##
=======================================
  Coverage   90.01%   90.02%           
=======================================
  Files         445      445           
  Lines       55926    55979   +53     
  Branches     5358     5365    +7     
=======================================
+ Hits        50341    50394   +53     
  Misses       4177     4177           
  Partials     1408     1408           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@alexarice
Copy link
Collaborator Author

@compor I believe you last touched this code, do you know what the intended behaviour is supposed to be?

Comment on lines +18 to +19
"unregistered_op"() : () -> ()
scf.yield
Copy link
Member

Choose a reason for hiding this comment

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

Am I missing something?

Suggested change
"unregistered_op"() : () -> ()
scf.yield
"unregistered_op"() : () -> ()

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

You're missing that I believe this doesn't verify as the implicit terminator isn't added, due to an unrelated problem this pr was trying to solve. (scf.for expects to be terminated by an scf.yield)

Copy link
Member

Choose a reason for hiding this comment

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

I'm confused, does this test not pass on main?

Copy link
Member

Choose a reason for hiding this comment

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

OK I just tested it out myself and became more confused :) I think a part of the problem is that the code in the printer is a little backwards, and would benefit from a comment. It might also benefit from a bit of a refactor, it feels a little wasteful to check for terminator trait for every operation that we print, when they can only be the last operation in the block. That's probably out of scope for this PR though.

Comment on lines +18 to +19
"unregistered_op"() : () -> ()
scf.yield
Copy link
Member

Choose a reason for hiding this comment

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

OK I just tested it out myself and became more confused :) I think a part of the problem is that the code in the printer is a little backwards, and would benefit from a comment. It might also benefit from a bit of a refactor, it feels a little wasteful to check for terminator trait for every operation that we print, when they can only be the last operation in the block. That's probably out of scope for this PR though.

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.

Thanks for the fix!

@alexarice alexarice merged commit 2fb1cab into main Oct 18, 2024
14 checks passed
@alexarice alexarice deleted the alexarice/unregistered branch October 18, 2024 15:13
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
`scf.for` prints it's blocks without terminators if there are no
`iter_args`. Unfortunately the check for whether an operation is a
terminator returns true by default for unregistered operations
(presumably so that they don't break verification), and so they don't
get printed.

This change should make it so that these ops always get printed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working core xDSL core (ir, textual format, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants