Skip to content

Commit

Permalink
In tasklets, indices show up only when the dimensions are larger than
Browse files Browse the repository at this point in the history
`1`.
  • Loading branch information
pratyai committed Jan 12, 2025
1 parent 3ad9f82 commit 7e0a9ca
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions dace/frontend/fortran/ast_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,21 @@ def write_code(self, node: ast_internal_classes.FNode):
raise NameError("Error in code generation" + node.__class__.__name__)

def arraysub2string(self, node: ast_internal_classes.Array_Subscript_Node):
str_to_return = self.write_code(node.name) + "[" + self.write_code(node.indices[0])
for i in node.indices[1:]:
str_to_return += ", " + self.write_code(i)
str_to_return += "]"
return str_to_return
name = node.name
# We need to look up the array to find its shape -- its access behave differently based on the dimension sizes.
arr_name = self.mapping.get(self.sdfg).get(name.name)
assert arr_name is not None, f"Variable name not found: {name.name}"
assert self.sdfg.arrays.get(arr_name) is not None, f"Variable name not found: {name.name}"
arr = self.sdfg.arrays[arr_name]

assert (not arr.shape and not node.indices) or len(arr.shape) == len(node.indices)
# Ignore 1-sized dimensions if the arrays are on input/output connectors.
perceived_indices = [i for s, i in zip(arr.shape, node.indices) if s != 1] if arr.shape else []
arr = self.write_code(name)
if not perceived_indices:
return arr
acc = ', '.join(self.write_code(i) for i in perceived_indices)
return f"{arr}[{acc}]"

def name2string(self, node):
if isinstance(node, str):
Expand Down

0 comments on commit 7e0a9ca

Please sign in to comment.