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

Function test_vectorized_popcount

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

Source from the content-addressed store, hash-verified

729@pytest.mark.gpu
730@pytest.mark.skipif(not env.has_cuda(), reason="need cuda")
731def test_vectorized_popcount():
732 def ref_popcount(x):
733 cnt = 0
734 while x:
735 x -= x & -x
736 cnt += 1
737 return cnt
738
739 def run_test(dtype):
740 n = 128
741 f = sched(lambda x: tvm.tirx.popcount(x), dtype, n)
742 dev = tvm.cuda(0)
743 a = tvm.runtime.tensor(np.random.randint(0, 100000, size=n).astype(dtype), dev)
744 b = tvm.runtime.tensor(np.zeros(shape=(n,)).astype(dtype), dev)
745 f(a, b)
746 ref = np.vectorize(ref_popcount)(a.numpy())
747 tvm.testing.assert_allclose(b.numpy(), ref)
748
749 run_test("uint32")
750 run_test("uint64")
751
752
753@pytest.mark.gpu

Callers

nothing calls this directly

Calls 1

run_testFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…