-
Notifications
You must be signed in to change notification settings - Fork 28
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
Conversation
Codecov Report
@@ 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
Continue to review full report at Codecov.
|
src/exo/LoopIR_scheduling.py
Outdated
@@ -767,103 +768,102 @@ def __init__(self, proc, stmt): | |||
self.orig_proc = proc | |||
self.win_stmt = stmt | |||
|
|||
print(proc) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for debugging?
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
…o bounds checking more generally
…y checks for aliasing and config variables as procedure arguments, both of which could lead to unsound analyses, and the latter of which was causing problems for fixing the loop fissioning checks
@gilbo Should this be closed then? Are these commits contained in the merged PR? |
No. I need to work on this next. It’s another massive PR to fix the underlying analysis
… On Jul 29, 2022, at 6:29 PM, Yuka Ikarashi ***@***.***> wrote:
@gilbo Should this be closed then? Are these commits contained in the merged PR?
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you were mentioned.
|
@@ -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)') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's happening??
There was a problem hiding this comment.
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) } |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
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]>
@@ -174,6 +174,9 @@ def __init__(self, pat, proc, stmt, scope): | |||
else: | |||
self.srcinfo = stmt.srcinfo | |||
|
|||
assert scope == "before", ("Non-before scope for parsing " |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change merged in #277
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) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changed merged in #277
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change merged in #277
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) | ||
|
There was a problem hiding this comment.
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
assert isinstance(expr, (LoopIR.Read, LoopIR.StrideExpr, | ||
LoopIR.Const)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes merged in #277
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}.") |
There was a problem hiding this comment.
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]): |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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): |
There was a problem hiding this comment.
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
* 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]>
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)