move all VIEW -> LOAD rules to big graph rewrite [pr] (#7936)

* move all VIEW -> LOAD rules to big graph rewrite [pr]

* comments
This commit is contained in:
qazal
2024-11-28 01:02:29 -05:00
committed by GitHub
parent e2eccdab43
commit e3fe7023b0

View File

@@ -183,7 +183,6 @@ to_si = PatternMatcher([
lazy = PatternMatcher([
(UPat(tuple(Ops), name="x"), lambda ctx,x: ctx.metadata.add(m) if (m:=ctx.ops_metadata.get(x)) is not None else None),
(UPat(Ops.BUFFER, name="b").view(name="v"), lambda ctx,b,v: UOp(Ops.PRELOAD if b in ctx.assigns else Ops.LOAD, v.dtype, (b, v.st.to_uop()))),
(UPat(Ops.CONTIGUOUS, src=(UPat.var("x"),)), lambda ctx,x: x),
])
@@ -372,6 +371,8 @@ break_sched = PatternMatcher([
(UPatSrc({Ops.CONST, Ops.BIND}), generate_valid),
# everything else is a VIEW of BUFFER that either realizes or fuses
(UPatSrc(), lambda ctx,b,to_store,base: append_kernel(ctx, b, to_store, base) if b in ctx.realizes else append_op(ctx, b, to_store)),
# just load realized buffers
(UPat(Ops.BUFFER, name="b").view(name="v"), lambda ctx,b,v: UOp(Ops.PRELOAD if b in ctx.assigns else Ops.LOAD, v.dtype, (b, v.st.to_uop()))),
])
@track_rewrites(named=True)