forked from tinygrad/tinygrad
clean up unneeded dtype check in rules [PR] (#17845)
Autogen / In-tree Autogen (macos) (push) Waiting to run
Benchmarks / Mac pytest (push) Waiting to run
Benchmarks / LLM (DEV=AMD) (push) Waiting to run
Benchmarks / LLM (DEV=METAL) (push) Waiting to run
Benchmarks / LLM (DEV=NV) (push) Waiting to run
Benchmarks / HLB-CIFAR10 (DEV=AMD) (push) Waiting to run
Benchmarks / HLB-CIFAR10 (DEV=METAL) (push) Waiting to run
Benchmarks / HLB-CIFAR10 (DEV=NV) (push) Waiting to run
Benchmarks / MLPerf (AMD) (push) Waiting to run
Benchmarks / MLPerf (NV) (push) Waiting to run
Benchmarks / Stable Diffusion (DEV=AMD) (push) Waiting to run
Benchmarks / Stable Diffusion (DEV=METAL) (push) Waiting to run
Benchmarks / Stable Diffusion (DEV=NV) (push) Waiting to run
Benchmarks / Multi-GPU Benchmarks (DEV=AMD) (push) Waiting to run
Benchmarks / Multi-GPU Benchmarks (DEV=NV) (push) Waiting to run
Benchmarks / Tests (DEV=AMD) (push) Waiting to run
Benchmarks / Tests (DEV=METAL) (push) Waiting to run
Benchmarks / Tests (DEV=NV) (push) Waiting to run
Benchmarks / UsbGPU Benchmark (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 dmonitoring (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 dmonitoring (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 policy (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 supercombo (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 vision (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 dmonitoring (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 dmonitoring (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 policy (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 supercombo (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 vision (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / DSP Benchmark (push) Waiting to run
Benchmarks / UsbGPU Benchmark (comma) (push) Waiting to run
Benchmarks / PCI Driver Benchmark (DEV=AMD) (push) Waiting to run
Benchmarks / PCI Driver Benchmark (DEV=NV) (push) Waiting to run
Benchmarks / LLVM Speed (push) Waiting to run
Platform Tests / MacOS (unit) (push) Waiting to run
Platform Tests / MacOS (unit, mock) (push) Waiting to run
Platform Tests / MacOS (DEV=METAL) (1) (push) Waiting to run
Platform Tests / MacOS (DEV=METAL) (2) (push) Waiting to run
Platform Tests / MacOS (DEV=CPU:CLANG) (push) Waiting to run
Platform Tests / MacOS (DEV=CPU:LLVM) (push) Waiting to run
Platform Tests / MacOS (DEV=CPU:LVP) (push) Waiting to run
Platform Tests / MacOS (DEV=WEBGPU) (push) Waiting to run
Platform Tests / Windows (DEV=CPU:CLANG) (push) Waiting to run
Platform Tests / Windows (DEV=CPU:LLVM) (push) Waiting to run
Platform Tests / Windows (DEV=CPU:X86) (push) Waiting to run
Platform Tests / Windows (DEV=WEBGPU) (push) Waiting to run
Unit Tests / Models (push) Successful in 1m40s
Unit Tests / Linux (DSP) (push) Successful in 1m49s
Unit Tests / ONNX (CPU) Tests (push) Successful in 2m4s
Unit Tests / Linters (push) Successful in 2m6s
Unit Tests / Test LLM (push) Successful in 2m28s
Unit Tests / hcq2 (push) Successful in 2m35s
Unit Tests / Fuzzing (push) Successful in 2m41s
Unit Tests / openpilot Compile Tests (push) Successful in 3m5s
Unit Tests / Null Tests (push) Successful in 3m10s
Unit Tests / Torch Backend Training (push) Successful in 3m13s
Unit Tests / Docs (push) Successful in 3m21s
Unit Tests / AMD ASM IDE (push) Successful in 3m21s
Unit Tests / Unit Tests (push) Successful in 3m24s
Unit Tests / Linux (amdllvm gfx1100) (push) Successful in 3m22s
Unit Tests / CL IMAGE Tests (push) Successful in 3m29s
Unit Tests / Linux (DEV=CPU:LVP) (push) Successful in 3m31s
Unit Tests / Linux (DEV=CPU:LLVM) (push) Successful in 3m38s
Unit Tests / Python Backend (push) Successful in 3m40s
Unit Tests / Linux (DEV=CL) (push) Successful in 3m42s
Unit Tests / Optimization Tests (push) Successful in 3m44s
Unit Tests / Linux (DEV=CPU:X86) (push) Successful in 3m52s
Unit Tests / SPEC=2 (1) (push) Successful in 3m55s
Unit Tests / Linux (am) (push) Successful in 3m59s
Unit Tests / Linux (amdllvm gfx1201) (push) Successful in 4m0s
Unit Tests / Torch Backend Tests (push) Successful in 4m11s
Unit Tests / Compile-only (DEV=NULL:NAK:sm_120) (push) Successful in 1m37s
Unit Tests / Linux (DEV=WEBGPU) (push) Successful in 4m16s
Unit Tests / SPEC=2 (2) (push) Successful in 4m20s
Unit Tests / Linux (amd gfx1201) (push) Successful in 4m22s
Unit Tests / Linux (amd gfx1100) (push) Successful in 4m24s
Unit Tests / Linux (DEV=CPU:CLANG) (push) Successful in 4m44s
Unit Tests / Compile-only (DEV=NULL:IR3:a630) (push) Successful in 2m18s
Unit Tests / Linux (amdllvm gfx950) (push) Successful in 2m59s
Deploy Docs / deploy (push) Successful in 5m2s
Unit Tests / Linux (ptx) (push) Successful in 3m3s
Unit Tests / Linux (nv) (push) Successful in 3m46s
Unit Tests / Linux (amd gfx950) (push) Successful in 4m9s
Unit Tests / Compile-only (DEV=NULL:QCOMCL:a630) (push) Successful in 3m42s
Autogen / In-tree Autogen (push) Successful in 12m5s
Autogen / In-tree Autogen (macos) (push) Waiting to run
Benchmarks / Mac pytest (push) Waiting to run
Benchmarks / LLM (DEV=AMD) (push) Waiting to run
Benchmarks / LLM (DEV=METAL) (push) Waiting to run
Benchmarks / LLM (DEV=NV) (push) Waiting to run
Benchmarks / HLB-CIFAR10 (DEV=AMD) (push) Waiting to run
Benchmarks / HLB-CIFAR10 (DEV=METAL) (push) Waiting to run
Benchmarks / HLB-CIFAR10 (DEV=NV) (push) Waiting to run
Benchmarks / MLPerf (AMD) (push) Waiting to run
Benchmarks / MLPerf (NV) (push) Waiting to run
Benchmarks / Stable Diffusion (DEV=AMD) (push) Waiting to run
Benchmarks / Stable Diffusion (DEV=METAL) (push) Waiting to run
Benchmarks / Stable Diffusion (DEV=NV) (push) Waiting to run
Benchmarks / Multi-GPU Benchmarks (DEV=AMD) (push) Waiting to run
Benchmarks / Multi-GPU Benchmarks (DEV=NV) (push) Waiting to run
Benchmarks / Tests (DEV=AMD) (push) Waiting to run
Benchmarks / Tests (DEV=METAL) (push) Waiting to run
Benchmarks / Tests (DEV=NV) (push) Waiting to run
Benchmarks / UsbGPU Benchmark (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 dmonitoring (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 dmonitoring (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 policy (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 supercombo (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 vision (DEV=QCOM) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 dmonitoring (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 dmonitoring (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 policy (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.2 compile3 supercombo (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / openpilot 0.11.0 compile3 vision (DEV=QCOM:IR3) (push) Waiting to run
Benchmarks / DSP Benchmark (push) Waiting to run
Benchmarks / UsbGPU Benchmark (comma) (push) Waiting to run
Benchmarks / PCI Driver Benchmark (DEV=AMD) (push) Waiting to run
Benchmarks / PCI Driver Benchmark (DEV=NV) (push) Waiting to run
Benchmarks / LLVM Speed (push) Waiting to run
Platform Tests / MacOS (unit) (push) Waiting to run
Platform Tests / MacOS (unit, mock) (push) Waiting to run
Platform Tests / MacOS (DEV=METAL) (1) (push) Waiting to run
Platform Tests / MacOS (DEV=METAL) (2) (push) Waiting to run
Platform Tests / MacOS (DEV=CPU:CLANG) (push) Waiting to run
Platform Tests / MacOS (DEV=CPU:LLVM) (push) Waiting to run
Platform Tests / MacOS (DEV=CPU:LVP) (push) Waiting to run
Platform Tests / MacOS (DEV=WEBGPU) (push) Waiting to run
Platform Tests / Windows (DEV=CPU:CLANG) (push) Waiting to run
Platform Tests / Windows (DEV=CPU:LLVM) (push) Waiting to run
Platform Tests / Windows (DEV=CPU:X86) (push) Waiting to run
Platform Tests / Windows (DEV=WEBGPU) (push) Waiting to run
Unit Tests / Models (push) Successful in 1m40s
Unit Tests / Linux (DSP) (push) Successful in 1m49s
Unit Tests / ONNX (CPU) Tests (push) Successful in 2m4s
Unit Tests / Linters (push) Successful in 2m6s
Unit Tests / Test LLM (push) Successful in 2m28s
Unit Tests / hcq2 (push) Successful in 2m35s
Unit Tests / Fuzzing (push) Successful in 2m41s
Unit Tests / openpilot Compile Tests (push) Successful in 3m5s
Unit Tests / Null Tests (push) Successful in 3m10s
Unit Tests / Torch Backend Training (push) Successful in 3m13s
Unit Tests / Docs (push) Successful in 3m21s
Unit Tests / AMD ASM IDE (push) Successful in 3m21s
Unit Tests / Unit Tests (push) Successful in 3m24s
Unit Tests / Linux (amdllvm gfx1100) (push) Successful in 3m22s
Unit Tests / CL IMAGE Tests (push) Successful in 3m29s
Unit Tests / Linux (DEV=CPU:LVP) (push) Successful in 3m31s
Unit Tests / Linux (DEV=CPU:LLVM) (push) Successful in 3m38s
Unit Tests / Python Backend (push) Successful in 3m40s
Unit Tests / Linux (DEV=CL) (push) Successful in 3m42s
Unit Tests / Optimization Tests (push) Successful in 3m44s
Unit Tests / Linux (DEV=CPU:X86) (push) Successful in 3m52s
Unit Tests / SPEC=2 (1) (push) Successful in 3m55s
Unit Tests / Linux (am) (push) Successful in 3m59s
Unit Tests / Linux (amdllvm gfx1201) (push) Successful in 4m0s
Unit Tests / Torch Backend Tests (push) Successful in 4m11s
Unit Tests / Compile-only (DEV=NULL:NAK:sm_120) (push) Successful in 1m37s
Unit Tests / Linux (DEV=WEBGPU) (push) Successful in 4m16s
Unit Tests / SPEC=2 (2) (push) Successful in 4m20s
Unit Tests / Linux (amd gfx1201) (push) Successful in 4m22s
Unit Tests / Linux (amd gfx1100) (push) Successful in 4m24s
Unit Tests / Linux (DEV=CPU:CLANG) (push) Successful in 4m44s
Unit Tests / Compile-only (DEV=NULL:IR3:a630) (push) Successful in 2m18s
Unit Tests / Linux (amdllvm gfx950) (push) Successful in 2m59s
Deploy Docs / deploy (push) Successful in 5m2s
Unit Tests / Linux (ptx) (push) Successful in 3m3s
Unit Tests / Linux (nv) (push) Successful in 3m46s
Unit Tests / Linux (amd gfx950) (push) Successful in 4m9s
Unit Tests / Compile-only (DEV=NULL:QCOMCL:a630) (push) Successful in 3m42s
Autogen / In-tree Autogen (push) Successful in 12m5s
This commit is contained in:
@@ -84,7 +84,7 @@ def get_simplifying_rewrite_patterns(ops:tuple[Ops, ...]) -> PatternMatcher:
|
||||
if Ops.AND in ops: pat.append((UPat.var("x", dtypes.ints)%UPat.cvar("c"), lambda x,c: x & (c.val-1) if c.val in powers_of_two else None))
|
||||
pat.append((UPat.var("a")%UPat.var("b"), floormod_to_mod))
|
||||
# no real hardware supports THREEFRY, but NullRenderer does
|
||||
if Ops.THREEFRY not in ops: pat.append((UPat(Ops.THREEFRY, dtype=dtypes.uint64, src=(UPat.var("x"), UPat.var("key"))), threefry2x32))
|
||||
if Ops.THREEFRY not in ops: pat.append((UPat(Ops.THREEFRY, src=(UPat.var("x"), UPat.var("key"))), threefry2x32))
|
||||
# MAX can be rewritten as CMPLT + WHERE (max function is annoying on many cstyle backends)
|
||||
if Ops.MAX not in ops and Ops.CMPLT in ops: pat.append((UPat(Ops.MAX, name="m"), lambda m: (m.src[0] < m.src[1]).where(m.src[1], m.src[0])))
|
||||
return PatternMatcher(pat)
|
||||
|
||||
@@ -84,7 +84,7 @@ def reduce_unparented(red:UOp) -> UOp|None:
|
||||
assert all(x.op is Ops.RANGE for x in red.src[1:]), "some reduce srcs aren't ranges"
|
||||
reduce_parented, reduce_unparented = partition(red.src[1:], lambda x: x in red.src[0].ranges)
|
||||
if len(reduce_unparented) == 0: return None
|
||||
ret = red.replace(src=(red.src[0],)+tuple(reduce_parented)) if len(reduce_parented) or red.dtype != red.src[0].dtype else red.src[0]
|
||||
ret = red.replace(src=(red.src[0],)+tuple(reduce_parented)) if len(reduce_parented) else red.src[0]
|
||||
if red.arg[0] is Ops.ADD:
|
||||
for r in reduce_unparented: ret = ret * r.src[0]
|
||||
if red.arg[0] is Ops.MUL:
|
||||
|
||||
@@ -377,7 +377,7 @@ isel_matcher = PatternMatcher([
|
||||
(UPat(GroupOp.Comparison, src=(UPat(dtype=dtypes.float64), UPat()), name="m").where(UPat.var("a", dtypes.float64), UPat.var("b")), lambda m,a,b:
|
||||
a.ins(X86Ops.VBLENDVPD, src=(b, a, mask(m)))),
|
||||
# in this case we have a mask producing comparison whose user expects a bool, so we convert to bool
|
||||
(UPat(GroupOp.Comparison, dtypes.bool, (UPat.var("y", (dtypes.float32, dtypes.float64)), UPat()), name="x"), lambda y,x:
|
||||
(UPat(GroupOp.Comparison, src=(UPat.var("y", (dtypes.float32, dtypes.float64)), UPat()), name="x"), lambda y,x:
|
||||
UOp(Ops.AND, src=(mask(x).bitcast(dt:=to_int(y.dtype)), UOp.cconst(1, dt))).bitcast(dtypes.bool)),
|
||||
# conditional moves that use flags
|
||||
# TODO: remove this once we allow all flag producing ops in cmove
|
||||
@@ -394,10 +394,10 @@ isel_matcher = PatternMatcher([
|
||||
(UPat(Ops.IF, src=(UPat(Ops.CMPEQ, name="y"),), name="x"), lambda y,x: x.ins(X86Ops.JE, src=(cmp(y),))),
|
||||
(UPat(Ops.IF, src=(UPat(Ops.CMPNE, name="y"),), name="x"), lambda y,x: x.ins(X86Ops.JNE, src=(cmp(y),))),
|
||||
# comparisons whose user doesn't use the flag, move flag result to register
|
||||
(UPat(Ops.CMPLT, dtypes.bool, (UPat(dtype=dtypes.uints), UPat()), name="x"), lambda x: x.ins(X86Ops.SETB, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPLT, dtypes.bool, name="x"), lambda x: x.ins(X86Ops.SETL, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPEQ, dtypes.bool, name="x"), lambda x: x.ins(X86Ops.SETE, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPNE, dtypes.bool, name="x"), lambda x: x.ins(X86Ops.SETNE, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPLT, src=(UPat(dtype=dtypes.uints), UPat()), name="x"), lambda x: x.ins(X86Ops.SETB, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPLT, name="x"), lambda x: x.ins(X86Ops.SETL, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPEQ, name="x"), lambda x: x.ins(X86Ops.SETE, src=(cmp(x),))),
|
||||
(UPat(Ops.CMPNE, name="x"), lambda x: x.ins(X86Ops.SETNE, src=(cmp(x),))),
|
||||
# float unary
|
||||
(UPat.var("y", dtypes.float32).sqrt().named("x"), lambda y,x: x.ins(X86Ops.VSQRTSS, src=(y, y)) if x.max_numel() == 1 else x.ins(X86Ops.VSQRTPS)),
|
||||
(UPat.var("y", dtypes.float64).sqrt().named("x"), lambda y,x: x.ins(X86Ops.VSQRTSD, src=(y, y)) if x.max_numel() == 1 else x.ins(X86Ops.VSQRTPD)),
|
||||
|
||||
@@ -38,7 +38,7 @@ def _mop_index(r:UOp, idx:UOp):
|
||||
if r.op is Ops.RESHAPE:
|
||||
src_prefix = len(r.src[0].shape) - len(r.shape[len(idxs):])
|
||||
if src_prefix >= 0 and r.src[0].shape[src_prefix:] == r.shape[len(idxs):]:
|
||||
if src_prefix == 0: return r.src[0] if r.src[0].dtype == idx.dtype else None
|
||||
if src_prefix == 0: return r.src[0]
|
||||
ret = r.src[0].index(*apply_movement_op(r.op, r.src[0].shape[:src_prefix], r.shape[:len(idxs)], idxs), arg=idx.arg)
|
||||
return ret if ret.shape == idx.shape else None
|
||||
|
||||
|
||||
Reference in New Issue
Block a user