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

OMNI: Fix dimension range-indexing in frontend #363

Merged
merged 8 commits into from
Aug 26, 2024

Conversation

mlange05
Copy link
Collaborator

@mlange05 mlange05 commented Aug 23, 2024

Just testing for now ...

This change adds a frontend sanitisation step to remove the forced lower bounds on array declaration dimensions in OMNI. This is done via a custom sanitisation Transformer.

As a result, we can remove a lot of the special-casing for OMNI's array dimension notation and, importantly, remove the use of the normalize_range_indexing utility across the loki.transformation sub-package tests. Consequently, we can also remove the OMNI special-casing in loki_transform.py - the problem that triggered this entire endeavour.

Please note, the normalize_range_indexing tool has not been removed, as it has a legitimate use in another sanitisation utility, which is part of the C-transpilation toolchain. However, all OMNI-specific workarounds using this utility have been removed.

Copy link

Documentation for this branch can be viewed at https://sites.ecmwf.int/docs/loki/363/index.html

@mlange05 mlange05 force-pushed the naml-omni-fix-range-indexing branch 5 times, most recently from ff1a188 to 5a10e51 Compare August 23, 2024 17:51
Copy link

codecov bot commented Aug 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.40%. Comparing base (9a76c21) to head (29a4869).
Report is 9 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #363      +/-   ##
==========================================
- Coverage   95.41%   95.40%   -0.02%     
==========================================
  Files         177      178       +1     
  Lines       37332    37267      -65     
==========================================
- Hits        35622    35555      -67     
- Misses       1710     1712       +2     
Flag Coverage Δ
lint_rules 96.39% <ø> (ø)
loki 95.38% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@mlange05 mlange05 force-pushed the naml-omni-fix-range-indexing branch from 5a10e51 to 7fed99e Compare August 24, 2024 03:57
@mlange05 mlange05 marked this pull request as ready for review August 24, 2024 04:20
Copy link
Collaborator

@reuterbal reuterbal left a comment

Choose a reason for hiding this comment

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

Many thanks, I absolutely love it!

for v in self.retriever.retrieve(o.symbols):
dimensions = tuple(d.upper if self.is_one_index(d) else d for d in v.dimensions)
_type = v.type
if v.shape:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Note that v.shape is only an indirection to v.type.shape:

def shape(self):
"""
Original allocated shape of the variable as a tuple of dimensions.
"""
return self.type.shape

Since you've already looked up the type, you might as well use _type.shape here and in the line below, to avoid hitting the symbol table again

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good spot! Pushed a fix.

@reuterbal reuterbal added the ready for merge This PR has been approved and is ready to be merged label Aug 26, 2024
@reuterbal reuterbal merged commit 68cb274 into main Aug 26, 2024
13 checks passed
@reuterbal reuterbal deleted the naml-omni-fix-range-indexing branch August 26, 2024 08:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready for merge This PR has been approved and is ready to be merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants