MCPcopy Index your code
hub / github.com/apache/tvm / test_matmul_offload

Function test_matmul_offload

tests/python/relax/test_codegen_cutlass.py:387–428  ·  view source on GitHub ↗
(
    x_shape,
    y_shape,
    transpose_y,
    epilogue,
    residual_block,
    dtype,
)

Source from the content-addressed store, hash-verified

385 ],
386)
387def test_matmul_offload(
388 x_shape,
389 y_shape,
390 transpose_y,
391 epilogue,
392 residual_block,
393 dtype,
394):
395 with_bias, activation = _epilogue_table[epilogue]
396 var_table = {}
397 concrete_x_shape = _to_concrete_shape(x_shape, var_table)
398 concrete_y_shape = _to_concrete_shape(y_shape, var_table)
399 x = np.random.randn(*concrete_x_shape).astype(dtype)
400 y = np.random.randn(*concrete_y_shape).astype(dtype)
401
402 if transpose_y:
403 y = np.swapaxes(y, -2, -1)
404 y_shape = (*y_shape[:-2], y_shape[-1], y_shape[-2])
405
406 if with_bias:
407 bias = np.random.randn(concrete_y_shape[-1]).astype(dtype)
408 args = (x, y, bias)
409 else:
410 bias = None
411 args = (x, y)
412
413 residual_bin_op, residual_activation = _residual_block_table[residual_block]
414
415 mod = get_relax_matmul_module(
416 x_shape,
417 y_shape,
418 dtype,
419 bias_shape=bias.shape if with_bias else None,
420 transposed_y=transpose_y,
421 activation=activation,
422 residual_bin_op=residual_bin_op,
423 residual_activation=residual_activation,
424 )
425 out = get_result_with_relax_cutlass_offload(mod, *args)
426 ref = build_and_run(mod, args, "llvm")
427
428 tvm.testing.assert_allclose(out, ref, rtol=1e-2, atol=1e-2)
429
430
431def test_matmul_with_3d_bias_offload():

Callers

nothing calls this directly

Calls 5

get_relax_matmul_moduleFunction · 0.90
_to_concrete_shapeFunction · 0.70
build_and_runFunction · 0.70
astypeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…