Skip to content

Commit

Permalink
Make is_empty() and propagate_subset() not unnecessarily rely on …
Browse files Browse the repository at this point in the history
…the `src` and `dst` (#1699)
  • Loading branch information
pratyai authored Oct 24, 2024
1 parent 380554f commit 0217f26
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 15 deletions.
20 changes: 9 additions & 11 deletions dace/memlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ def is_empty(self) -> bool:
primarily used for connecting nodes to scopes without transferring
data to them.
"""
return (self.data is None and self.src_subset is None and self.dst_subset is None)
return (self.data is None and self.subset is None and self.other_subset is None)

@property
def num_accesses(self):
Expand Down Expand Up @@ -561,20 +561,18 @@ def used_symbols(self, all_symbols: bool, edge=None) -> Set[str]:
view_edge = True

if not view_edge:
if self.src_subset:
result |= self.src_subset.free_symbols

if self.dst_subset:
result |= self.dst_subset.free_symbols
if self.subset:
result |= self.subset.free_symbols
if self.other_subset:
result |= self.other_subset.free_symbols
else:
# View edges do not require the end of the range nor strides
if self.src_subset:
for rb, _, _ in self.src_subset.ndrange():
if self.subset:
for rb, _, _ in self.subset.ndrange():
if symbolic.issymbolic(rb):
result |= set(map(str, rb.free_symbols))

if self.dst_subset:
for rb, _, _ in self.dst_subset.ndrange():
if self.other_subset:
for rb, _, _ in self.other_subset.ndrange():
if symbolic.issymbolic(rb):
result |= set(map(str, rb.free_symbols))

Expand Down
13 changes: 9 additions & 4 deletions dace/sdfg/propagation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1430,10 +1430,15 @@ def propagate_subset(memlets: List[Memlet],
tmp_subset = None

subset = None
if use_dst and md.dst_subset is not None:
subset = md.dst_subset
elif not use_dst and md.src_subset is not None:
subset = md.src_subset
src, dst = md.subset, md.other_subset
if md._is_data_src is not None:
# Ideally, this should always be the case. In practice, it is not always so. So, if the memlet is uninitialized
# for some reason, we just explicitly fallback to `subset` and `other_subset` to retain the prior behaviour.
src, dst = md.src_subset, md.dst_subset
if use_dst and dst is not None:
subset = dst
elif not use_dst and src is not None:
subset = src
else:
subset = md.subset

Expand Down

0 comments on commit 0217f26

Please sign in to comment.