MCPcopy
hub / github.com/tinygrad/tinygrad / custom_elementwise_addmul_kernel

Function custom_elementwise_addmul_kernel

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

Source from the content-addressed store, hash-verified

26 return C[i].store(A[i]+B[i]).end(i).sink(arg=KernelInfo(name=f"custom_add_kernel_{C.numel()}")).simplify()
27
28def custom_elementwise_addmul_kernel(C:UOp, D:UOp, A:UOp, B:UOp) -> UOp:
29 C,D,A,B = C.flatten(), D.flatten(), A.flatten(), B.flatten()
30 assert C.numel() == D.numel()
31 i = UOp.range(C.numel(), 0)
32 store_c = C[i].store(A[i]+B[i])
33 store_d = D[i].store(A[i]*B[i])
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]

Callers

nothing calls this directly

Calls 9

KernelInfoClass · 0.90
flattenMethod · 0.80
numelMethod · 0.80
rangeMethod · 0.45
storeMethod · 0.45
simplifyMethod · 0.45
sinkMethod · 0.45
endMethod · 0.45
groupMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…