MCPcopy Create free account
hub / github.com/apache/tvm / blockwise_matmul

Function blockwise_matmul

tests/python/contrib/test_cutlass_gemm.py:248–272  ·  view source on GitHub ↗
(
    x_fp8_np: np.ndarray,
    x_scale_np: np.ndarray,
    w_np: np.ndarray,
    w_scale_np: np.ndarray,
    block_size: tuple[int, int],
    dtype: str,
)

Source from the content-addressed store, hash-verified

246
247
248def blockwise_matmul(
249 x_fp8_np: np.ndarray,
250 x_scale_np: np.ndarray,
251 w_np: np.ndarray,
252 w_scale_np: np.ndarray,
253 block_size: tuple[int, int],
254 dtype: str,
255):
256 o_np = np.zeros((x_fp8_np.shape[0], w_np.shape[0]), dtype=dtype)
257 for j in range(w_scale_np.shape[0]):
258 for k in range(w_scale_np.shape[1]):
259 o_np[:, j * block_size[0] : min((j + 1) * block_size[0], w_np.shape[0])] += (
260 np.matmul(
261 x_fp8_np[
262 :, k * block_size[1] : min((k + 1) * block_size[1], x_fp8_np.shape[1])
263 ].astype(dtype),
264 w_np[
265 j * block_size[0] : min((j + 1) * block_size[0], w_np.shape[0]),
266 k * block_size[1] : min((k + 1) * block_size[1], w_np.shape[1]),
267 ].T.astype(dtype),
268 )
269 * x_scale_np[:, k : k + 1]
270 * w_scale_np[j, k]
271 )
272 return o_np
273
274
275def blockwise_bmm(

Callers 1

Calls 4

minFunction · 0.50
zerosMethod · 0.45
matmulMethod · 0.45
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…