-
Notifications
You must be signed in to change notification settings - Fork 130
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix missed exploration of edges in constant propagation (#1635)
There is a bug related to the missed exploration of interstate edges during constant propagation in case a loop body has a conditional assignment. The reverse DFS yields parent-node pairs and analyzes only the edge connecting the two. The DFS will yield a certain node only once, while the assumption in the code is that the uniqueness is enforced on the parent-node pair. This results in only one outgoing interstate edge per body state being visited, leading to mistakes in the common case of conditional assignments (which result in two outgoing edges performing different assignments). If the visited edge does not perform an assignment or assigns the initialization value, the symbol will be wrongly interpreted as a constant and replaced in downstream states. A short reproducing example is: ```python N = dace.symbol('N', dace.int64) @dace.program def program(in_arr: dace.bool[N], arr: dace.bool[N]): check = False for i in range(N): if in_arr[i]: check = True else: check = False for i in dace.map[0:N]: arr[i] = check sdfg = program.to_sdfg(simplify=True) sdfg.save('bug.sdfg') # "arr[i] = check" will be replaced by "arr[i] = False" ``` The fix makes sure all interstate edges are visited at least once.
- Loading branch information
1 parent
0a2c55a
commit 7210cb6
Showing
2 changed files
with
72 additions
and
85 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters