Skip to content

Commit

Permalink
edit code comment
Browse files Browse the repository at this point in the history
  • Loading branch information
edopao committed Jan 24, 2025
1 parent ccd70db commit 950c856
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/gt4py/next/program_processors/runners/dace/gtir_dataflow.py
Original file line number Diff line number Diff line change
Expand Up @@ -543,6 +543,11 @@ def _visit_deref(self, node: gtir.FunCall) -> DataExpr:
return self._deref_list(arg_expr, field_desc)

def _deref_scalar(self, arg_expr: IteratorExpr, field_desc: dace.data.Array) -> ValueExpr:
"""
Lower deref of a field of scalar values to a tasklet that perform array access.
The tasklet allows to use runtime values as access indices.
"""
field_offset = [offset for (_, offset) in arg_expr.field_domain]
field_indices = [(dim, arg_expr.indices[dim]) for dim, _ in arg_expr.field_domain]

Expand All @@ -564,7 +569,7 @@ def _deref_scalar(self, arg_expr: IteratorExpr, field_desc: dace.data.Array) ->
for dim, index in field_indices
)
deref_node = self._add_tasklet(
"runtime_deref",
"deref_scalar",
{"field"} | set(index_connectors),
{"val"},
code=f"val = field[{index_internals}]",
Expand Down Expand Up @@ -603,6 +608,11 @@ def _deref_scalar(self, arg_expr: IteratorExpr, field_desc: dace.data.Array) ->
return self._construct_tasklet_result(field_desc.dtype, deref_node, "val")

def _deref_list(self, arg_expr: IteratorExpr, field_desc: dace.data.Array) -> ValueExpr:
"""
Lower deref of a field of lists (a sparse field) to a tasklet that perform array access.
The tasklet allows to use runtime values as access indices.
"""
assert isinstance(arg_expr.gt_dtype, ts.ListType)
assert arg_expr.gt_dtype.offset_type is not None
offset_type = arg_expr.gt_dtype.offset_type
Expand Down Expand Up @@ -631,7 +641,7 @@ def _deref_list(self, arg_expr: IteratorExpr, field_desc: dace.data.Array) -> Va
for dim, index in field_indices
)
deref_node = self._add_tasklet(
"runtime_deref",
"deref_list",
{"field"} | set(index_connectors),
{"val"},
code=f"""
Expand Down

0 comments on commit 950c856

Please sign in to comment.