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

feat: First Batch of Translators #20

Merged

Conversation

philip-paul-mueller
Copy link
Contributor

@philip-paul-mueller philip-paul-mueller commented Sep 13, 2024

This PR introduces a series of primitive translators, most of them are based on the prototype, with some improvements.
I just copied them over from the development branch, which is not so nice, but was the simplest thing to to without also introducing the other stuff.

It is important that the tests from the development branch were not added, to keep the PR small.
Furthermore, we need something to test, so this PR must go first.

For organizational reasons, the development history of this PR happened to be contained in PR#21.

I just copied them and did not do a merge, which is not so nice.
Furthermore, the tests are not yet there, in my view it makes sense to first have something that can be checked.
Before it was implementewd as a switch, for the case JAX would use the bool overload of XLA.
The check for this was now essentially moved inside the function.
@codecov-commenter
Copy link

codecov-commenter commented Sep 13, 2024

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 54.54545% with 200 lines in your changes missing coverage. Please review.

Please upload report for BASE (main@19c89b0). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...nslator/primitive_translators/gather_translator.py 14.81% 46 Missing ⚠️
src/jace/translator/post_translation.py 6.25% 30 Missing ⚠️
...c/jace/translator/primitive_translators/slicing.py 37.77% 28 Missing ⚠️
...ace/translator/primitive_translators/conditions.py 29.03% 22 Missing ⚠️
...ive_translators/convert_element_type_translator.py 44.44% 15 Missing ⚠️
...or/primitive_translators/concatenate_translator.py 36.84% 12 Missing ⚠️
...ranslator/primitive_translators/pjit_translator.py 50.00% 10 Missing ⚠️
...lator/primitive_translators/select_n_translator.py 61.53% 10 Missing ⚠️
...imitive_translators/broadcast_in_dim_translator.py 73.68% 5 Missing ⚠️
...slator/primitive_translators/squeeze_translator.py 75.00% 5 Missing ⚠️
... and 7 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #20   +/-   ##
=======================================
  Coverage        ?   69.23%           
=======================================
  Files           ?       31           
  Lines           ?     1235           
  Branches        ?      251           
=======================================
  Hits            ?      855           
  Misses          ?      314           
  Partials        ?       66           

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

Copy link
Collaborator

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

It looks good. Just some code style comments.

src/jace/translator/jaxpr_translator_builder.py Outdated Show resolved Hide resolved
src/jace/translator/jaxpr_translator_builder.py Outdated Show resolved Hide resolved
src/jace/translator/jaxpr_translator_builder.py Outdated Show resolved Hide resolved
src/jace/translator/jaxpr_translator_builder.py Outdated Show resolved Hide resolved
src/jace/translator/mapped_operation_base_translator.py Outdated Show resolved Hide resolved
src/jace/translator/primitive_translators/slicing.py Outdated Show resolved Hide resolved
src/jace/translator/primitive_translators/slicing.py Outdated Show resolved Hide resolved
src/jace/translator/primitive_translators/slicing.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@egparedes egparedes left a comment

Choose a reason for hiding this comment

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

LGTM. I only found a couple of typos and small optional suggestions, so I don't need another review round.


else:
dims_to_bcast = [
dim for dim in range(out_rank) if in_shape[dim] == 1 and out_shape[dim] != 1
Copy link
Collaborator

Choose a reason for hiding this comment

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

Optional suggestion:

Suggested change
dim for dim in range(out_rank) if in_shape[dim] == 1 and out_shape[dim] != 1
dim for dim in range(out_rank) if in_shape[dim] == 1 != out_shape[dim]

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I did not know that this is possible, however, I do not think that it is very readable the a < x < b is useful but here I do not like it that much,

Co-authored-by: Enrique González Paredes <enriqueg@cscs.ch>
@philip-paul-mueller philip-paul-mueller merged commit 0a9f361 into GridTools:main Sep 26, 2024
4 checks passed
@philip-paul-mueller philip-paul-mueller deleted the new_translators branch September 26, 2024 14:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants