diff --git a/dace/transformation/passes/transient_reuse.py b/dace/transformation/passes/transient_reuse.py index 0eacec1cf0..805ddadff4 100644 --- a/dace/transformation/passes/transient_reuse.py +++ b/dace/transformation/passes/transient_reuse.py @@ -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 @@ -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