MCPcopy Create free account
hub / github.com/FlashSampling/FlashSampling / test_argsort_2d

Function test_argsort_2d

tests/test_tl_argsort.py:73–83  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

71
72
73def test_argsort_2d():
74 M, N = 4, 128 # noqa: N806
75 x = torch.randn(M, N, dtype=torch.float32, device="cuda")
76 out_vals = torch.empty_like(x)
77 out_ids = torch.empty(M, N, dtype=torch.int32, device="cuda")
78
79 argsort_2d_kernel[(M,)](x, out_vals, out_ids, stride_m=N, N=N, M=M)
80
81 expected_vals, expected_ids = torch.sort(x, dim=-1, descending=True)
82 assert torch.allclose(out_vals, expected_vals)
83 assert torch.equal(out_ids, expected_ids.to(torch.int32))

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected