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: remove generic and generic check from TypedAttribute #3504

Merged
merged 1 commit into from
Nov 22, 2024

Conversation

alexarice
Copy link
Collaborator

As discussed in #3492, this check feels unnecessary and is unwanted for making DenseIntOrFPElementsAttr a TypedAttribute

@alexarice alexarice added the core xDSL core (ir, textual format, ...) label Nov 22, 2024
@alexarice alexarice self-assigned this Nov 22, 2024
Copy link

codecov bot commented Nov 22, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 90.34%. Comparing base (020cae7) to head (dffa305).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3504      +/-   ##
==========================================
- Coverage   90.34%   90.34%   -0.01%     
==========================================
  Files         464      464              
  Lines       58052    58037      -15     
  Branches     5550     5549       -1     
==========================================
- Hits        52448    52434      -14     
  Misses       4177     4177              
+ Partials     1427     1426       -1     

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


🚨 Try these New Features:

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.

Do you know why it was added in the first place? I'm wondering why it wasn't just using OO, is it for precise placement of the type variable in the list of parameters? It feels like that should be possible by redeclaring the type property at the desired index. Do you feel like that would be worth a go? It would also decouple the dense stuff, I have a feeling.

@alexarice
Copy link
Collaborator Author

I'm not really sure why it was there, and @math-fehr wasn't sure either. I kind of feel that enforcing that the type appear as a parameter at all rather than just as an interface method on TypedAttribute is overkill, but I guess it was there for irdl things.

I'm actually really struggling to get all the variances correct on dense PR atm so any suggestions on sorting this stuff would be good.

@superlopuh
Copy link
Member

Would you like me to have a go at my own suggestion?

@alexarice
Copy link
Collaborator Author

Go for it. I'm starting to wonder if the generic parameter on TypedAttribute can be removed completely

@superlopuh
Copy link
Member

My attempt was a failure, let's go back to this idea. Is there any way to keep the unit test deleted here? So we keep the fact that the type is indeed the same as the TypedAttribute parameter, but check it differently?

@alexarice
Copy link
Collaborator Author

Is there any way to keep the unit test deleted here?

What do you mean?

@superlopuh
Copy link
Member

Like to make the check work differently, instead of looking for the parameter of the Generic, look for the parameter of `TypedAttribute1?

@alexarice
Copy link
Collaborator Author

I would prefer just to remove the generic parameter on TypedAttribute

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.

I just had a comment but otherwise nice!

xdsl/irdl/attributes.py Show resolved Hide resolved
@alexarice
Copy link
Collaborator Author

@superlopuh you happy with this (and the next PR)?

@superlopuh
Copy link
Member

Oh this is a case where I think I'm only happy with this together with the next PR, as after this PR we can declare something as typed with a certain type, but remove the code that verifies this at runtime. If TypedAttribute is no longer generic then this PR is dead code elimination.

@alexarice
Copy link
Collaborator Author

Should I merge the 2 PRs?

@superlopuh
Copy link
Member

I would recommend mergint them in one go, yep

@alexarice
Copy link
Collaborator Author

Great, I'm just merging main into the second one to update FloatAttr

@alexarice
Copy link
Collaborator Author

That did not work...

@alexarice alexarice force-pushed the alexarice/typed-attribute-generic branch from e0224a8 to dffa305 Compare November 22, 2024 17:15
@alexarice alexarice changed the title core: remove generic check on TypedAttribute core: remove generic and generic check from TypedAttribute Nov 22, 2024
@alexarice alexarice requested a review from superlopuh November 22, 2024 17:18
@alexarice alexarice merged commit beb38f2 into main Nov 22, 2024
15 checks passed
@alexarice alexarice deleted the alexarice/typed-attribute-generic branch November 22, 2024 17:23
EdmundGoodman pushed a commit to EdmundGoodman/xdsl that referenced this pull request Dec 6, 2024
…ct#3504)

`TypedAttribute` was using some needlessly complicated python generic typing, which was making other changes difficult. This commit removes this.
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.

3 participants