Skip to content

Commit

Permalink
Fixes to SDFG inlining for structures
Browse files Browse the repository at this point in the history
  • Loading branch information
phschaad committed Jan 15, 2025
1 parent d0c04a5 commit 7f2c273
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
23 changes: 19 additions & 4 deletions dace/transformation/interstate/sdfg_nesting.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,11 +427,26 @@ def apply(self, state: SDFGState, sdfg: SDFG):

orig_data: Dict[Union[nodes.AccessNode, MultiConnectorEdge], str] = {}
for node in nstate.nodes():
if isinstance(node, nodes.AccessNode) and node.data in repldict:
orig_data[node] = node.data
node.data = repldict[node.data]
if isinstance(node, nodes.AccessNode):
if '.' in node.data:
parts = node.data.split('.')
root_container = parts[0]
if root_container in repldict:
orig_data[node] = node.data
full_data = [repldict[root_container]] + parts[1:]
node.data = '.'.join(full_data)
elif node.data in repldict:
orig_data[node] = node.data
node.data = repldict[node.data]
for edge in nstate.edges():
if edge.data.data in repldict:
if '.' in edge.data.data:
parts = edge.data.data.split('.')
root_container = parts[0]
if root_container in repldict:
orig_data[edge] = edge.data.data
full_data = [repldict[root_container]] + parts[1:]
edge.data.data = '.'.join(full_data)
elif edge.data.data in repldict:
orig_data[edge] = edge.data.data
edge.data.data = repldict[edge.data.data]

Expand Down
3 changes: 3 additions & 0 deletions dace/transformation/passes/lift_struct_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@


import sys

from dace.transformation.transformation import explicit_cf_compatible
if sys.version_info >= (3, 8):
from typing import Literal
dirtype = Literal['in', 'out']
Expand Down Expand Up @@ -348,6 +350,7 @@ def _data_containers_in_ast(node: ast.AST, arrnames: Set[str]) -> Set[str]:
result.add(data)
return result

@explicit_cf_compatible
class LiftStructViews(ppl.Pass):
"""
Lift direct accesses to struct members to accesses to views pointing to that struct member.
Expand Down

0 comments on commit 7f2c273

Please sign in to comment.