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

Api Audit and Fixing Up Effect Checks #191

Closed
wants to merge 24 commits into from
Closed

Conversation

gilbo
Copy link
Contributor

@gilbo gilbo commented May 11, 2022

This PR will collect all of my work to make sure the new effect checks are working.

This PR will not yet try to deprecate or strip out the old effect system.

This PR will also not yet try to replace the old bounds check with the new effect-checking machinery. (Another PR should replace the bounds checking / assert checking, and then yet another PR can strip out the old effect checking stuff entirely)

@codecov
Copy link

codecov bot commented May 11, 2022

Codecov Report

Merging #191 (4a53990) into master (4264975) will decrease coverage by 2.10%.
The diff coverage is 83.50%.

❗ Current head 4a53990 differs from pull request most recent head 15815b4. Consider uploading reports for the commit 15815b4 to get more accurate results

@@            Coverage Diff             @@
##           master     #191      +/-   ##
==========================================
- Coverage   84.72%   82.61%   -2.11%     
==========================================
  Files          66       66              
  Lines       14633    14906     +273     
==========================================
- Hits        12398    12315      -83     
- Misses       2235     2591     +356     
Impacted Files Coverage Δ
src/exo/pyparser.py 73.45% <ø> (-0.04%) ⬇️
src/exo/API.py 71.60% <60.71%> (-0.87%) ⬇️
src/exo/LoopIR_scheduling.py 83.53% <78.82%> (-0.44%) ⬇️
src/exo/new_eff.py 89.58% <95.45%> (+1.22%) ⬆️
src/exo/new_analysis_core.py 80.43% <100.00%> (+0.17%) ⬆️
src/exo/parse_fragment.py 67.09% <100.00%> (-29.66%) ⬇️
src/exo/platforms/gemmini.py 94.17% <100.00%> (+0.03%) ⬆️
tests/gemmini/conv/test_gemmini_conv_ae.py 100.00% <100.00%> (ø)
tests/test_schedules.py 100.00% <100.00%> (ø)
tests/amx/test_amx_instr.py 11.19% <0.00%> (-88.81%) ⬇️
... and 16 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4264975...15815b4. Read the comment docs.

@@ -767,103 +768,102 @@ def __init__(self, proc, stmt):
self.orig_proc = proc
self.win_stmt = stmt

print(proc)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this for debugging?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I assume so; it's gone now.

@@ -393,8 +393,6 @@ def parse_num_type(self, node, is_arg = False):
if isinstance(node.slice, pyast.Tuple):
dims = node.slice.elts
else:
assert isinstance(node.slice,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you delete this assert?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe I relaxed the constraint that dependent sizes are simple (i.e. only a name or constant). It seems we already have all the infrastructure to support expressions in tensor types but never removed this check. If you're concerned this might break something, maybe we can add some tests to increase our confidence?

@yamaguchi1024
Copy link
Member

@gilbo Should this be closed then? Are these commits contained in the merged PR?

@gilbo
Copy link
Contributor Author

gilbo commented Jul 30, 2022 via email

@yamaguchi1024 yamaguchi1024 marked this pull request as ready for review November 3, 2022 16:30
@@ -942,7 +946,7 @@ def do_st_acc_i8(
st_acc_i8_s2_v2 = st_acc_i8_s2_v2.reorder_stmts('src_tmp = _', 'ConfigStore.scale = _')
st_acc_i8_s2_v2 = st_acc_i8_s2_v2.reorder_stmts('src_tmp : _', 'ConfigStore.scale = _')
st_acc_i8_s2_v2 = st_acc_i8_s2_v2.fission_after('ConfigStore.scale = _', n_lifts=2)
st_acc_i8_s2_v2 = st_acc_i8_s2_v2.configwrite_after('ConfigStore.scale = _', ConfigStore, 'dst_stride', 'stride(dst, 2)')
st_acc_i8_s2_v2 = st_acc_i8_s2_v2.configwrite_after('ConfigStore.scale = _', ConfigStore, 'dst_stride', 'stride(dst, 1)')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's happening??

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should create a stride typecheck test

"an allocation might be buried "
"in a different scope than some use-site")
pass
#pre_allocs = { s.name for s in pre if isinstance(s,LoopIR.Alloc) }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this commented out?


# --------------------------------------------------------------------------- #
# --------------------------------------------------------------------------- #
# The Passes to export

class Schedules:
DoRenameBuf = _DoRenameBuf
DoAssignNewVarBefore = _DoAssignNewVarBefore
DoDeleteDeadCode = _DoDeleteDeadCode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should go through the motivation of these primitives together and also write tests

yamaguchi1024 added a commit that referenced this pull request Nov 4, 2022
This PR is partially merging #191, which was authored by Gilbert

* merge partition_loop

* merge small assert in parse_fragment

* merge lift_if changes

* merge FV

* merge lift_alloc_simple

* Update src/exo/LoopIR_scheduling.py

Co-authored-by: Alex Reinking <[email protected]>

* Update src/exo/LoopIR_scheduling.py

Co-authored-by: Alex Reinking <[email protected]>

* Update src/exo/LoopIR_scheduling.py

Co-authored-by: Alex Reinking <[email protected]>

* Update src/exo/LoopIR_scheduling.py

Co-authored-by: Alex Reinking <[email protected]>

Co-authored-by: Alex Reinking <[email protected]>
@yamaguchi1024 yamaguchi1024 marked this pull request as draft November 4, 2022 23:36
@@ -174,6 +174,9 @@ def __init__(self, pat, proc, stmt, scope):
else:
self.srcinfo = stmt.srcinfo

assert scope == "before", ("Non-before scope for parsing "
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change merged in #277

Comment on lines +265 to +290
def test_lift_alloc_simple3(golden):
@proc
def bar(n: size, A: i8[n]):
for k in seq(0, n):
for i in seq(0, n):
for j in seq(0, n):
tmp_a: i8
tmp_a = A[i]

bar = bar.lift_alloc_simple('tmp_a : _', n_lifts=3)
assert str(bar) == golden

def test_lift_alloc_simple_fv_error():
@proc
def bar(n: size, A: i8[n]):
for k in seq(0, n):
for i in seq(0, n):
for j in seq(0, n):
tmp_a: i8[k + 1]
tmp_a[k] = A[i]

with pytest.raises(SchedulingError,
match='Cannot lift allocation statement'):
bar = bar.lift_alloc_simple('tmp_a : _', n_lifts=3)


Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed merged in #277

Comment on lines +1 to +6
def bar(n: size, A: i8[n] @ DRAM):
tmp_a: i8 @ DRAM
for k in seq(0, n):
for i in seq(0, n):
for j in seq(0, n):
tmp_a = A[i]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change merged in #277

Comment on lines 111 to 116
def __init__(self, proc, loop_stmt, num):
self.stmt = loop_stmt
self.partition_by = num
self.second = False
self.second_iter = None

super().__init__(proc)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All changes to _PartitionLoop were merged in #277

Comment on lines +966 to +967
assert isinstance(expr, (LoopIR.Read, LoopIR.StrideExpr,
LoopIR.Const))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes merged in #277

Comment on lines -1409 to +1571
raise SchedulingError("specified lift level {self.n_lifts} "+
"is higher than the number of loop "+
"{len(self.ctrl_ctxt)}")
raise SchedulingError(f"specified lift level {self.n_lifts} "
f"is more than {len(self.ctrl_ctxt)}, "
f"the number of loops "
f"and ifs above the allocation")
if len(s.type.shape()) > 0:
szvars = set.union(*[ _FV(sz) for sz in s.type.shape() ])
for i in self.get_ctrl_iters():
if i in szvars:
raise SchedulingError(
f"Cannot lift allocation statement {s} past loop "
f"with iteration variable {i} because "
f"the allocation size depends on {i}.")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed merged in #277

@@ -625,10 +801,10 @@ def bar(n: size, src: [R][n], dst: [R][n]):
dst[i] = src[i] + src[i + 1]

@proc
def foo(x: R[50, 2]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes applied in #307

@@ -48,6 +49,7 @@ def __init__(self, proc, subproc, stmt_block):
self.live_vars = ChainMap()

super().__init__(proc)
Check_Aliasing(self.proc)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes were applied in #307

@@ -1192,13 +1264,13 @@ def __init__(self, proc, if_stmt, n_lifts):
assert is_pos_int(n_lifts)

self.target = if_stmt
self.loop_deps = vars_in_expr(if_stmt.cond)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_DoLiftIf is deprecated now


# remove when _DoDoubleFission is removed
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cannot be deprecated yet, still used in _FissionLoops

@@ -1,2 +1,2 @@
def foo(x: R[50, 2] @ DRAM):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes were applied in #307

yamaguchi1024 added a commit that referenced this pull request Jan 31, 2023
* Changes to `_InlineWindow`

* Changes to `_CallSwap`

* `Check_Aliasing` in `_BindConfig` and `_BindExpr`

* Changes to `_DoExpandDim`

* Changes to `_DoRearrangeDim`

* Changes to `_DoRemoveLoop`

* Changes to `_DoFissionAfterSimple`

* Changes to `_DoFuseIf`

* Added `fuse_loop` tests

* Changes to `_DoAddLoop`

* Changes to `_DoExtractMethod`

* Changes to `_AssertIf`

* Changes to `_DoDataReuse`

* Changes to `_DoStageWindow`

* Changes to `_DoBoundAlloc`

* Changes to `DoReplace`

* Update commented line in `_DoAddUnsafeGuard`

* fixed AMX test error

* Update src/exo/LoopIR_scheduling.py

---------

Co-authored-by: Kevin Qian <[email protected]>
Co-authored-by: Yuka Ikarashi <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants