(bcast_length)
| 224 | @pytest.mark.gpu |
| 225 | @pytest.mark.skipif(not env.has_cuda_compute(8), reason="need cuda compute >= 8.0") |
| 226 | def test_half_broadcast(bcast_length): |
| 227 | dtype = "float16" |
| 228 | |
| 229 | def _create_mod(bcast_length, dtype): |
| 230 | @I.ir_module(s_tir=True) |
| 231 | class Module: |
| 232 | @T.prim_func(s_tir=True) |
| 233 | def main(a: T.Buffer((), dtype), vec: T.Buffer((bcast_length,), dtype)): |
| 234 | for i_0 in T.thread_binding(1, thread="blockIdx.x"): |
| 235 | for i_1 in T.thread_binding(1, thread="threadIdx.x"): |
| 236 | with T.sblock("broadcast"): |
| 237 | vec[0:bcast_length] = T.broadcast(a[()], bcast_length) |
| 238 | |
| 239 | return Module |
| 240 | |
| 241 | mod = _create_mod(bcast_length, dtype) |
| 242 | target = "cuda" |
| 243 | func = tvm.compile(mod, target=target) |
| 244 | dev = tvm.device(target, 0) |
| 245 | |
| 246 | a_np = np.random.uniform(low=0, high=4, size=()).astype(dtype) |
| 247 | a = tvm.runtime.tensor(a_np, device=dev) |
| 248 | b = tvm.runtime.empty((bcast_length,), dtype=dtype, device=dev) |
| 249 | |
| 250 | func(a, b) |
| 251 | |
| 252 | b_np = np.full((bcast_length,), a_np) |
| 253 | |
| 254 | tvm.testing.assert_allclose(b.numpy(), b_np) |
| 255 | |
| 256 | |
| 257 | vector_length = tvm.testing.parameter(2, 4) |
nothing calls this directly
no test coverage detected
searching dependent graphs…