mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-30 18:46:08 +00:00
remove const/var from the kernel graph [pr] (#9240)
This commit is contained in:
@@ -252,6 +252,9 @@ def append_to_kernel(ctx:KernelContext, x:UOp):
|
||||
create_kernels = merge_views+PatternMatcher([
|
||||
(UPat(GroupOp.All-{Ops.KERNEL, Ops.BUFFER}, name="x"), create_kernel),
|
||||
(UPat(Ops.KERNEL, name="x"), append_to_kernel),
|
||||
# remove CONST/BIND from the kernel graph
|
||||
(UPat(Ops.SINK, name="x"), lambda x: x.replace(src=new_src)
|
||||
if (new_src:=tuple(dedup(s.base for s in x.src if s.op not in {Ops.CONST,Ops.BIND}))) != x.src else None),
|
||||
])
|
||||
|
||||
# **** fix kernel AST
|
||||
|
||||
+1
-3
@@ -126,9 +126,7 @@ kernel_spec = buffer_spec+PatternMatcher([
|
||||
(UPat(Ops.KERNEL, src=UPat((Ops.BUFFER, Ops.ASSIGN))), lambda: True),
|
||||
# assign has a buffer view and kernel source, it can optionally depend on other assigns
|
||||
(UPat(Ops.ASSIGN, src=UPat((Ops.BUFFER, Ops.VIEW, Ops.KERNEL, Ops.ASSIGN))), lambda: True),
|
||||
# view/sink/const/bind/var can also exist in the kernel graph
|
||||
(UPat((Ops.VIEW, Ops.SINK, Ops.CONST, Ops.BIND, Ops.DEFINE_VAR)), lambda: True),
|
||||
(UPat(GroupOp.All), lambda: False),
|
||||
(UPat(GroupOp.All-{Ops.SINK, Ops.VIEW}), lambda: False),
|
||||
])
|
||||
|
||||
# *** this is the UOp shape spec ***
|
||||
|
||||
Reference in New Issue
Block a user