Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delete_pass to delete the loop if the body is empty #212

Merged
merged 1 commit into from
Jul 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/exo/LoopIR_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -2516,6 +2516,12 @@ class _DoDeletePass(LoopIR_Rewrite):
def map_s(self, s):
if isinstance(s, LoopIR.Pass):
return []
elif isinstance(s, (LoopIR.ForAll, LoopIR.Seq)):
body = self.map_stmts(s.body)
if not body:
return []
else:
return [s.update(body=body)]
else:
return super().map_s(s)

Expand Down
2 changes: 2 additions & 0 deletions tests/golden/test_schedules/test_delete_pass.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def foo(x: R @ DRAM):
x = 0.0
17 changes: 17 additions & 0 deletions tests/test_schedules.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,23 @@
from exo.parse_fragment import ParseFragmentError


def test_delete_pass(golden):
@proc
def foo(x : R):
pass
x = 0.0

assert str(foo.delete_pass()) == golden

@proc
def foo(x : R):
for i in seq(0, 16):
for j in seq(0, 2):
pass
x = 0.0

assert str(foo.delete_pass()) == golden

def test_add_loop1(golden):
@proc
def foo():
Expand Down