MCPcopy
hub / github.com/tinygrad/tinygrad / custom_gemm

Function custom_gemm

test/backend/test_custom_kernel.py:36–42  ·  view source on GitHub ↗
(C:UOp, A:UOp, B:UOp)

Source from the content-addressed store, hash-verified

34 return UOp.group(store_c, store_d).end(i).sink(arg=KernelInfo(name=f"custom_addmul_kernel_{C.numel()}")).simplify()
35
36def custom_gemm(C:UOp, A:UOp, B:UOp) -> UOp:
37 assert A.shape[1] == B.shape[0]
38 i, j, k = UOp.range(C.shape[0], 0), UOp.range(C.shape[1], 1), UOp.range(A.shape[1], 2, axis_type=AxisType.REDUCE)
39 C = C[i, j].set(0.0)
40 C = C[i, j].set(C.after(k)[i, j] + A[i, k] * B[k, j], end=k)
41 prog = C.end(i, j)
42 return prog.sink(arg=KernelInfo(name=f"custom_gemm_{C.shape[0]}_{C.shape[1]}_{A.shape[1]}", opts_to_apply=()))
43
44def custom_sum(B:UOp, A:UOp) -> UOp:
45 i = UOp.range(A.shape[0], 0, axis_type=AxisType.REDUCE)

Callers

nothing calls this directly

Calls 6

KernelInfoClass · 0.90
rangeMethod · 0.45
setMethod · 0.45
afterMethod · 0.45
endMethod · 0.45
sinkMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…