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

Function test_cuda_vectorize_load

tests/python/codegen/test_target_codegen_cuda.py:217–250  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

215@pytest.mark.gpu
216@pytest.mark.skipif(not env.has_cuda(), reason="need cuda")
217def test_cuda_vectorize_load():
218 num_thread = 8
219
220 def check_cuda(dtype, n, lanes):
221 dev = tvm.cuda(0)
222 vec_dtype = f"{dtype}x{lanes}"
223 num_blocks = n // num_thread
224
225 @I.ir_module(s_tir=True)
226 class Module:
227 @T.prim_func(s_tir=True)
228 def main(A: T.Buffer((n,), vec_dtype), B: T.Buffer((n,), vec_dtype)):
229 T.func_attr({"tirx.noalias": True})
230 for i_0 in T.thread_binding(num_blocks, thread="blockIdx.x"):
231 for i_1 in T.thread_binding(num_thread, thread="threadIdx.x"):
232 with T.sblock("B"):
233 v_i = T.axis.spatial(n, i_0 * num_thread + i_1)
234 T.reads(A[v_i])
235 T.writes(B[v_i])
236 B[v_i] = A[v_i]
237
238 fun = tvm.compile(Module, target="cuda")
239
240 np_a = np.random.randint(low=-128, high=127, size=(n, lanes))
241 a = tvm.runtime.empty((n,), vec_dtype, dev).copyfrom(np_a)
242 b = tvm.runtime.empty((n,), vec_dtype, dev)
243 fun(a, b)
244 tvm.testing.assert_allclose(a.numpy(), b.numpy())
245
246 check_cuda("int8", 64, 2)
247 check_cuda("int8", 64, 3)
248 check_cuda("int8", 64, 4)
249 check_cuda("int8", 64, 8)
250 check_cuda("int8", 64, 16)
251
252
253@pytest.mark.gpu

Callers

nothing calls this directly

Calls 1

check_cudaFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…