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

Function test_matmul_offload

tests/python/relax/test_codegen_hipblas.py:120–159  ·  view source on GitHub ↗
(
    x_shape,
    y_shape,
    transpose_y,
    epilogue,
    in_dtype,
    out_dtype,
)

Source from the content-addressed store, hash-verified

118 ],
119)
120def test_matmul_offload(
121 x_shape,
122 y_shape,
123 transpose_y,
124 epilogue,
125 in_dtype,
126 out_dtype,
127):
128 with_bias, activation = _epilogue_table[epilogue]
129 var_table = {}
130 concrete_x_shape = _to_concrete_shape(x_shape, var_table)
131 concrete_y_shape = _to_concrete_shape(y_shape, var_table)
132 x = np.random.randn(*concrete_x_shape).astype(in_dtype)
133 y = np.random.randn(*concrete_y_shape).astype(in_dtype)
134
135 if transpose_y:
136 y = np.swapaxes(y, -2, -1)
137 y_shape = (*y_shape[:-2], y_shape[-1], y_shape[-2])
138
139 if with_bias:
140 bias = np.random.randn(concrete_y_shape[-1]).astype(out_dtype)
141 args = (x, y, bias)
142 else:
143 bias = None
144 args = (x, y)
145
146 mod = get_relax_matmul_module(
147 x_shape,
148 y_shape,
149 in_dtype,
150 out_dtype,
151 bias_shape=bias.shape if with_bias else None,
152 transposed_y=transpose_y,
153 activation=activation,
154 )
155
156 out = get_result_with_relax_cublas_offload(mod, args)
157 ref = build_and_run(mod, args, "llvm", legalize=True)
158
159 tvm.testing.assert_allclose(out, ref, rtol=1e-2, atol=1e-2)
160
161
162def test_hipblas_partition_matmul_without_bias():

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…