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: deprecate Block.from_callable and replace with builder/implicit builder #1119

Merged
merged 2 commits into from Jun 13, 2023

Conversation

superlopuh
Copy link
Member

This would unify the API a bit, and redirect users towards the Builders. I think the Builder API is ready for adoption, and the making the building more uniform would make the project more approachable.

@superlopuh superlopuh added the core xDSL core (ir, textual format, ...) label Jun 12, 2023
@superlopuh superlopuh self-assigned this Jun 12, 2023
@review-notebook-app
Copy link

Check out this pull request on  ReviewNB

See visual diffs & provide feedback on Jupyter Notebooks.


Powered by ReviewNB

@codecov
Copy link

codecov bot commented Jun 12, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.02 🎉

Comparison is base (32b8677) 87.01% compared to head (310a7de) 87.03%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1119      +/-   ##
==========================================
+ Coverage   87.01%   87.03%   +0.02%     
==========================================
  Files         137      137              
  Lines       20793    20845      +52     
  Branches     3131     3132       +1     
==========================================
+ Hits        18093    18143      +50     
- Misses       2181     2184       +3     
+ Partials      519      518       -1     
Impacted Files Coverage Δ
docs/Toy/toy/dialects/toy.py 68.01% <ø> (+0.31%) ⬆️
xdsl/dialects/affine.py 93.18% <ø> (-0.57%) ⬇️
xdsl/dialects/func.py 94.47% <ø> (-0.14%) ⬇️
xdsl/ir/core.py 86.76% <ø> (-0.42%) ⬇️
tests/dialects/test_affine.py 100.00% <100.00%> (ø)
tests/dialects/test_func.py 100.00% <100.00%> (ø)
xdsl/dialects/pdl.py 86.00% <100.00%> (+0.69%) ⬆️

... and 1 file with indirect coverage changes

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

@@ -1118,6 +1118,7 @@ class BlockCallback(Protocol):
def __call__(self, *args: BlockArgument) -> list[Operation]:
...

@deprecated("Please use Builder instead")
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not sure we want to deprecate this now?
At least, I don't see any replacement for it, as the only way is to either do it by hand or create an implicit builder.
Can we instead make BlockCallback take a builder as argument or something?

Copy link
Member Author

Choose a reason for hiding this comment

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

But there is a replacement for it, which is to create it by hand or use an implicit builder :)

Copy link
Member Author

Choose a reason for hiding this comment

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

I'd like to delete BlockCallback as soon as clients have migrated off

Copy link
Collaborator

Choose a reason for hiding this comment

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

Well, I think that's a problem to have only these two options. I feel that in general, we should have

  • The hand-way, which realistically no one should use
  • The manual builder way, which is the MLIR-like way
  • The implicit builder way, which is the nice xDSL way

But I'm actually fine with this PR, since none of these cases should require the from_callable

@math-fehr math-fehr self-requested a review June 12, 2023 11:26
Copy link
Collaborator

@webmiche webmiche left a comment

Choose a reason for hiding this comment

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

Hmm I am not 100% convinced yet that we want to do this. To me, the BlockCallback things are mainly useful as a sort of nicer syntax for creating blocks with arguments. I see that the implicit builder is an even better syntax, so I think the core Idea is a good one.

What I am uncertain (probably because I am a bit out of the loop on the builder) is whether we can have the same kinds of constructs in a builder as in a general Python functions. In particular, can we handle general python control flow (like say a loop adding dependent operations or an if-clause) in a nice, straightforward way?

@superlopuh
Copy link
Member Author

Yeah, they are all possible, as far as I can tell they're exactly equivalent. Ultimately they're both sugar around adding operations to a list of operations, in my understanding, hard to imagine where one would be more expressive than the other.

Copy link
Collaborator

@webmiche webmiche left a comment

Choose a reason for hiding this comment

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

Perfect, let's get it in then!

@superlopuh superlopuh merged commit daedd4a into main Jun 13, 2023
12 checks passed
@superlopuh superlopuh deleted the sasha/builder/remove-from-callable branch June 13, 2023 07:31
cigarichard pushed a commit to cigarichard/xdsl that referenced this pull request Jun 17, 2023
… builder (xdslproject#1119)

This would unify the API a bit, and redirect users towards the Builders.
I think the Builder API is ready for adoption, and the making the
building more uniform would make the project more approachable.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core xDSL core (ir, textual format, ...)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants