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

assumed size array handling for 'normalize_array_shape_and_access' #218

Merged
merged 3 commits into from
Jan 31, 2024

Conversation

MichaelSt98
Copy link
Collaborator

normalize_array_shape_and_access() didn't handle assumed size arrays correctly.
This is a proposed fix/extension.

Copy link

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

Copy link

codecov bot commented Jan 25, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (c86b83a) 92.26% compared to head (012255a) 92.26%.
Report is 26 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #218   +/-   ##
=======================================
  Coverage   92.26%   92.26%           
=======================================
  Files          96       96           
  Lines       17124    17135   +11     
=======================================
+ Hits        15799    15810   +11     
  Misses       1325     1325           
Flag Coverage Δ
lint_rules 96.22% <ø> (+<0.01%) ⬆️
loki 92.24% <100.00%> (-0.01%) ⬇️
transformations 91.52% <ø> (+0.07%) ⬆️

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.

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.

Thanks, looks good. Two suggestions where I think stuff could be simplified, otherwise GTG!

Comment on lines 507 to 508
return (isinstance(dim, sym.RangeIndex) and not dim.lower == 1 and not dim is None
and not dim.lower is None and not dim.upper is None)
Copy link
Collaborator

Choose a reason for hiding this comment

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

This expression looks odd, I think it could be simplified:

Suggested change
return (isinstance(dim, sym.RangeIndex) and not dim.lower == 1 and not dim is None
and not dim.lower is None and not dim.upper is None)
return isinstance(dim, sym.RangeIndex) and not (dim.lower == 1 or dim.lower is None or dim.upper is None)


vmap = {}
for v in FindVariables(unique=False).visit(routine.body):
if isinstance(v, sym.Array):
# skip if e.g., `array(len)`, passed as `call routine(array)`
if len(v.shape) != len(v.dimensions):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Shouldn't the only case be that v.dimensions is None? Otherwise, shape and dimensions should match or there's something fishy anyway.


def validate_routine(routine):
arrays = [var for var in FindVariables().visit(routine.body) if isinstance(var, Array)]
for arr in arrays:
# print(f"arr: {arr} | {all(not isinstance(shape, sym.RangeIndex) for shape in arr.shape)}")
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
# print(f"arr: {arr} | {all(not isinstance(shape, sym.RangeIndex) for shape in arr.shape)}")

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.

Thanks for making these changes, looks good now!

@reuterbal reuterbal added the ready for merge This PR has been approved and is ready to be merged label Jan 26, 2024
Copy link
Collaborator

@mlange05 mlange05 left a comment

Choose a reason for hiding this comment

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

Looks great, going in now. :shipit:

@mlange05 mlange05 merged commit f053835 into main Jan 31, 2024
12 checks passed
@mlange05 mlange05 deleted the nams_assumed_size_normalize_array_shape_and_access branch January 31, 2024 15:40
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.

3 participants