From 7ad2e0bf60b6c634bef806f00b41cc73cd9b2c23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Philip=20M=C3=BCller?= <147368808+philip-paul-mueller@users.noreply.github.com> Date: Wed, 21 Aug 2024 22:24:11 +0200 Subject: [PATCH] Made `TransientReuse` Less Verbose (#1622) 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 --- dace/transformation/passes/transient_reuse.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) 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