Skip to content

Commit

Permalink
keep CONST/BUFFER uops in tensor_map [pr] (tinygrad#9083)
Browse files Browse the repository at this point in the history
  • Loading branch information
Qazalin authored Feb 14, 2025
1 parent 6529706 commit 82ad0d2
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions tinygrad/engine/schedule.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ def replace_contiguous(ctx:dict[UOp, UOp], alu:UOp):
# substitute BITCAST/CONTIGUOUS with BUFFER_VIEW on DISK
(UPat((Ops.BITCAST, Ops.CONTIGUOUS), name="root"),
lambda root: root.replace(op=Ops.BUFFER_VIEW) if isinstance(root.device, str) and root.device.startswith("DISK") else None),
# remove CONST/BIND/BUFFER from SINK
(UPat(Ops.SINK, name="root"),
lambda root: UOp(Ops.SINK, root.dtype, new_src, root.arg)
if (new_src:=tuple(x for x in root.src if not x.is_realized and x.base.op not in {Ops.CONST, Ops.BIND})) != root.src else None),
])

remove_movement_ops = merge_views+PatternMatcher([
Expand Down Expand Up @@ -139,7 +135,7 @@ def realize_before_view(ctx:ScheduleContext, view:UOp, src:UOp, b:UOp, **kwargs)

do_realize = PatternMatcher([
# always realize SINK parents
(UPat(Ops.SINK, name="sink"), lambda ctx,sink: ctx.realizes.update((x.buf_uop, x) for x in sink.src)),
(UPat(Ops.SINK, name="s"), lambda ctx,s: ctx.realizes.update((x.buf_uop, x) for x in s.src if x.base.op not in {Ops.CONST,Ops.BIND,Ops.BUFFER})),
# always realize ASSIGN/CONTIGUOUS/COPY/BUFFER_VIEW
(UPatScheduled({Ops.ASSIGN, Ops.CONTIGUOUS, Ops.COPY, Ops.BUFFER_VIEW}), realize),
# realize before expand or unsafe pad ops
Expand Down

0 comments on commit 82ad0d2

Please sign in to comment.