Skip to content

Commit

Permalink
Made TransientReuse Less Verbose (#1622)
Browse files Browse the repository at this point in the history
Added a flag to the `TransientReuse` transformation that prevents the
transformation from unconditional printing of memory savings.
This commit changes the default behaviour, because now the report is not
printed, but must be explicitly activated.

Co-authored-by: Tal Ben-Nun <[email protected]>
  • Loading branch information
philip-paul-mueller and tbennun authored Aug 21, 2024
1 parent d4ae6f4 commit 7ad2e0b
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions dace/transformation/passes/transient_reuse.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ class TransientReuse(ppl.Pass):

CATEGORY: str = 'Memory Footprint Reduction'

verbose = properties.Property(
dtype=bool,
default=False,
desc="Print information about the memory reduction.",
)

def modifies(self) -> ppl.Modifies:
return ppl.Modifies.Descriptors | ppl.Modifies.AccessNodes

Expand Down Expand Up @@ -154,11 +160,12 @@ def apply_pass(self, sdfg: SDFG, _) -> Optional[Set[str]]:
edge.data.data = new

# Analyze memory savings and output them
memory_after = 0
for a in sdfg.arrays:
memory_after += sdfg.arrays[a].total_size * sdfg.arrays[a].dtype.bytes
if self.verbose:
memory_after = 0
for a in sdfg.arrays:
memory_after += sdfg.arrays[a].total_size * sdfg.arrays[a].dtype.bytes
print('memory before: ', memory_before, 'B')
print('memory after: ', memory_after, 'B')
print('memory savings: ', memory_before - memory_after, 'B')

print('memory before: ', memory_before, 'B')
print('memory after: ', memory_after, 'B')
print('memory savings: ', memory_before - memory_after, 'B')
return result or None

0 comments on commit 7ad2e0b

Please sign in to comment.