-
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.
Introduces a transformation that converts WCR to an augmented assignment. --------- Co-authored-by: Philipp Schaad <[email protected]>
- Loading branch information
1 parent
74a31cb
commit 51871a7
Showing
3 changed files
with
131 additions
and
7 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Copyright 2019-2024 ETH Zurich and the DaCe authors. All rights reserved. | ||
""" Tests WCRToAugAssign. """ | ||
|
||
import dace | ||
import numpy as np | ||
from dace.transformation.dataflow import WCRToAugAssign | ||
|
||
|
||
def test_tasklet(): | ||
|
||
@dace.program | ||
def test(): | ||
a = np.zeros((10,)) | ||
for i in dace.map[1:9]: | ||
a[i-1] += 1 | ||
return a | ||
|
||
sdfg = test.to_sdfg(simplify=False) | ||
sdfg.apply_transformations(WCRToAugAssign) | ||
|
||
val = sdfg() | ||
ref = test.f() | ||
assert(np.allclose(val, ref)) | ||
|
||
|
||
def test_mapped_tasklet(): | ||
|
||
@dace.program | ||
def test(): | ||
a = np.zeros((10,)) | ||
for i in dace.map[1:9]: | ||
a[i-1] += 1 | ||
return a | ||
|
||
sdfg = test.to_sdfg(simplify=True) | ||
sdfg.apply_transformations(WCRToAugAssign) | ||
|
||
val = sdfg() | ||
ref = test.f() | ||
assert(np.allclose(val, ref)) | ||
|
||
|
||
if __name__ == '__main__': | ||
test_tasklet() | ||
test_mapped_tasklet() |