-
Notifications
You must be signed in to change notification settings - Fork 49
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
refactor[cartesian]: readability improvements in gtir -> oir conversion and other cleanups #1630
Conversation
@egparedes is it okay to do such arguably stylistic/cosmetic changes? |
1f081ab
to
6004dbd
Compare
Fixed the newly added type hints. Apparently |
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.
LGTM
Sure, if the changes make the code better and don't break the coding conventions I don't see why not. I you update the PR to the current |
Oh nice. My python is a bit outdated so I just copy-pasted. Now that I've read up on it, I agree, we should just use the new-style annotations. I'll create a separate PR as suggested.
Let's wait and see if @twicki has anything to say about this PR today. If there's no response by Monday, we can safely merge next week. |
cscs-ci run |
@egparedes can you help me understand what the CI results from cscs mean? As far as I understand it looks like a one of the next tests failed on changes in the Could it be that there's a race condition or reading uninitialized values from memory or something? |
I've done this work in PR #1632. Let's merge PR #1632 first (I'll deal with any potential conflicts) because then it will be simpler to see which new "stringized" types I have introduced with this PR. |
|
sure, let's try and see - I'll rebase tomorrow once PR #1632 (new style type hints) is merged. That will anyway trigger updates in this branch too |
6004dbd
to
d8dd0f9
Compare
okay so I rebased onto |
In the past, the only way to create type hints for yet-to-be-defined types was to quote them. Since python 3.7 we can get rid of the quotes when using `annotations` from `__future__` instead. This is supposed to become the default in the future. This PR is a spin-off from #1630 (comment). Co-authored-by: Roman Cattaneo <>
Let's solve the merge conflicts again first, and then I'll try to take a look if this PR still fails to pass the tests |
Avoid the otherwise unused "result" variable and return directly.
No need for this `init()` function if we have a default value for the `parent` field.
No need to do this transformation manually. The same transformation is done inside `GridSubset.setInterval()` in case an `oir.Interval` is passed.
1. The extra mask statement around `oir.While` is unnecessary because the mask is already part of the loop's condition. 2. Cleanup naming to increase readability
All other backends (except the dace backend) have their IR in the backend-specific subfolder (e.g. `npir.py` inside the `numpy` folder). Let's do the same for the dace IR.
d8dd0f9
to
f49a04f
Compare
cscs-ci run |
CI seems to be more happy today 🎉 |
This is a follow-up from PR #1630. It combines two things 1. In `oir_to_npir`, we fix conditional `while` loops in `numpy` backend. After PR 1630 these were stuck under certain conditions. Tests coverage extended. 2. In `gtir_to_oir`, we cleaned up the now unused `mask` parameter, which was pre-PR 1630 needed to pass down the mask information. With PR 1630 we actually removed the need for that parameter to be passed along because we properly nest the nested statements.
Description
Being new to the codebase and in preparation of the GT4Py-DaCe bridge refactor I was reading a lot of code. Some things that caught my eye are summarized in this PR. Bigger changes include
daceir.py
into thedace/
backend folder. This follows the convention of all other backends who have their IR inside the backend folder. (last commit)gtir_to_oir.py
(the "Cleanup visit_*" commits): In my opinion, there's no point in shortening "statement" to "stmt". I wouldn't go as far as renaming the classes. For the renamed local variables, I think this adds a lot to readability.visit_While
ingtir_to_oir.py
was having an extra mask statement around thewhile
loop (in case a mask was defined. I inlined the potentialmask
with the condition ofwhile
loop.gtir_to_oir.py
don't translate every body statement into a singleMaskStmt
. Instead, create one (or two incase ofelse
)MaskStmt
with multiple statements in thebody
(which is already typed as a list of statements).Tested locally by running the test suite. All tests passing.
Requirements
If this PR contains code authored by new contributors please make sure:
AUTHORS.md
file adding the names of all the new contributors.