-
Notifications
You must be signed in to change notification settings - Fork 138
xDSL: Make dialect registration more intuitive #231
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
Conversation
|
@math-fehr could you check the filecheck tests on this? I had weird behavior on my machine earlier. Will retry this afternoon after making sure my MLIR is on the proper version. |
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
georgebisbas
left a comment
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.
Looks good, only minor comments
|
If we merge this before applying to all the other uses of |
I am planning to wait for Mathieu's feedback on this and then rewrite the rest within this PR. Then, we should not run into problems. |
math-fehr
left a comment
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.
Yes, we definitely want that, thanks!
I added a comment on the way I think we should structure the dialects.
I'll take a look tomorrow! |
Actually, I looked into this a bit deeper and found the cause. I fixed it in #232. Basically, we had a test that was testing mlir custom prints, but we only print generic form, so that always failed. I guess it still makes sense if you run it on your machine, then we have at least run it on two machines making weird MLIR versioning issues less likely. |
6bfb8a2 to
5ce990e
Compare
I restructured with that in mind. Could you re-review, @math-fehr ? |
5ce990e to
5289865
Compare
|
Hmm, I feel that this is quite hacky to be honest! |
|
Yes, I agree. I think I missunderstood you suggestion. This design makes more sense. Still, iterators won't work AFAIU, considering that you suggestion uses the global class. |
Why wouldn't them? unless I misunderstood something? |
5289865 to
172286a
Compare
|
I actually coded this last night and realized that we could do exactly that 👍 Small question: Why did you annotated with |
Codecov ReportBase: 81.48% // Head: 81.35% // Decreases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## main #231 +/- ##
==========================================
- Coverage 81.48% 81.35% -0.14%
==========================================
Files 29 29
Lines 5413 5347 -66
Branches 912 910 -2
==========================================
- Hits 4411 4350 -61
+ Misses 762 757 -5
Partials 240 240
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
|
I am guessing that the reason why the code coverage decreases with this PR is that I am removing tested lines from (Sanity check) Does this make sense, @georgebisbas? |
|
Do not worry you are fine: It is normal and minor |
172286a to
ec74928
Compare
| def get_attributes(self) -> Iterator[Attribute]: | ||
| return iter(self.__attributes) | ||
|
|
||
| def __call__(self, ctx: MLContext) -> None: |
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.
This function allows backward compatibility. Do we want that here?
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.
I would say that we shouldn't keep it, especially since we do not have many users yet.
What do you think @georgebisbas ? You know more than us about these things.
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.
Keeps compatibility for what exactly?
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.
Previously, we registered dialects with _ = Arith(ctx). This still allows to register dialects like this, hence keeping backward compatibility.
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.
ah ok, then keep it, but maybe add some comment that this may be deprecated in a future release?
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.
I added a print to stderr and a comment.
|
I updated this to a refactor of all dialects. Please give it another read (@math-fehr in particular). |
math-fehr
left a comment
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.
Thanks! Yes, this is what I meant!
That looks good to me, I just added some nit comments.
| def get_attributes(self) -> Iterator[Attribute]: | ||
| return iter(self.__attributes) | ||
|
|
||
| def __call__(self, ctx: MLContext) -> None: |
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.
I would say that we shouldn't keep it, especially since we do not have many users yet.
What do you think @georgebisbas ? You know more than us about these things.
| def get_attributes(self) -> Iterator[Attribute]: | ||
| return iter(self.__attributes) | ||
|
|
||
| def __call__(self, ctx: MLContext) -> None: |
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.
Keeps compatibility for what exactly?
f50e38b to
cdc3e8d
Compare
This PR drafts a new way of registering (and working with) dialects within xDSL. Firstly, it gives dialects its own abstraction (a
Dialectclass) that contains two lists, one for operations, one for attributes. Furthermore, it adds the callctx.register_dialectto theMLContextclass. Using this function, one can now register dialects by writing:instead of:
where f is basically just a useless variable.