MCPcopy Create free account
hub / github.com/tile-ai/tilelang / ref_program

Function ref_program

testing/python/kernel/test_tilelang_kernel_gemm_batched.py:95–109  ·  view source on GitHub ↗
(A, B)

Source from the content-addressed store, hash-verified

93 profiler = kernel.get_profiler()
94
95 def ref_program(A, B):
96 import torch
97
98 if trans_A:
99 A = A.transpose(-1, -2)
100 if trans_B:
101 B = B.transpose(-1, -2)
102 if in_dtype == T.float32:
103 # Convert float32 to tfloat32 because tfloat32 mma cannot truncate
104 # float32 automatically, -0x1000 meas
105 A = (A.contiguous().view(torch.int32) - 0x1000).view(torch.float32)
106 B = (B.contiguous().view(torch.int32) - 0x1000).view(torch.float32)
107 C = torch.matmul(A.to(torch.float), B.to(torch.float))
108 C = C.to(torch.__getattribute__(out_dtype))
109 return C
110
111 profiler.assert_allclose(ref_program, atol=1e-2, rtol=1e-2)
112

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…