()
| 729 | @pytest.mark.gpu |
| 730 | @pytest.mark.skipif(not env.has_cuda(), reason="need cuda") |
| 731 | def 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 |
nothing calls this directly
no test coverage detected
searching dependent graphs…