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

Function test_matmul_offload

tests/python/relax/test_codegen_cublas.py:207–246  ·  view source on GitHub ↗
(
    x_shape,
    y_shape,
    transpose_y,
    epilogue,
    in_dtype,
    out_dtype,
)

Source from the content-addressed store, hash-verified

205 ],
206)
207def test_matmul_offload(
208 x_shape,
209 y_shape,
210 transpose_y,
211 epilogue,
212 in_dtype,
213 out_dtype,
214):
215 with_bias, activation = _epilogue_table[epilogue]
216 var_table = {}
217 concrete_x_shape = _to_concrete_shape(x_shape, var_table)
218 concrete_y_shape = _to_concrete_shape(y_shape, var_table)
219 x = np.random.randn(*concrete_x_shape).astype(in_dtype)
220 y = np.random.randn(*concrete_y_shape).astype(in_dtype)
221
222 if transpose_y:
223 y = np.swapaxes(y, -2, -1)
224 y_shape = (*y_shape[:-2], y_shape[-1], y_shape[-2])
225
226 if with_bias:
227 bias = np.random.randn(concrete_y_shape[-1]).astype(out_dtype)
228 args = (x, y, bias)
229 else:
230 bias = None
231 args = (x, y)
232
233 mod = get_relax_matmul_module(
234 x_shape,
235 y_shape,
236 in_dtype,
237 out_dtype,
238 bias_shape=bias.shape if with_bias else None,
239 transposed_y=transpose_y,
240 activation=activation,
241 )
242
243 out = get_result_with_relax_cublas_offload(mod, args)
244 ref = build_and_run(mod, args, "llvm", legalize=True)
245
246 tvm.testing.assert_allclose(out, ref, rtol=1e-2, atol=1e-2)
247
248
249@pytest.mark.parametrize(

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…