Laurawly commented on a change in pull request #4867: [TOPI][CUDA] Enable vectorization on fp16 type URL: https://github.com/apache/incubator-tvm/pull/4867#discussion_r378516859
########## File path: topi/tests/python/test_topi_tensor.py ########## @@ -84,18 +84,41 @@ def check_device(device): for device in ["llvm"]: check_device(device) +def verify_vectorization(n, m, dtype): + def check_device(device): + if not tvm.runtime.enabled(device): + print("Skip because %s is not enabled" % device) + return + with tvm.target.create(device): + ctx = tvm.context(device, 0) + A = tvm.placeholder((n, m), name='A', dtype=dtype) + B = tvm.compute((n, m), lambda i, j: + A[i, j] + tvm.const(1, A.dtype), name='B') + S = topi.generic.schedule_elemwise(B) + + fun = tvm.build(S, [A, B], device) + np_A = tvm.nd.empty((n, m), A.dtype, ctx).copyfrom( + np.random.uniform(size=(n, m))) + np_B = tvm.nd.empty((n, m), B.dtype, ctx) + fun(np_A, np_B) + tvm.testing.assert_allclose(np_B.asnumpy(), np_A.asnumpy() + 1, rtol=1e-5) + + for device in ["cuda"]: + check_device(device) + +def test_vectorization(): + verify_vectorization(128, 128, "float16") Review comment: Same here. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services