Skip to content

Commit f709778

Browse files
authored
Merge pull request #2 from denix56/codex/fix-assertion-error-in-knn-test
Fix Triton pairwise grid sizing
2 parents fe21563 + 03a3d7a commit f709778

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

torch_cluster/triton.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,8 @@ def _triton_pairwise_distances(
181181
x = torch.nn.functional.normalize(x, dim=-1)
182182
y = torch.nn.functional.normalize(y, dim=-1)
183183
out = torch.empty((M, N), device=x.device, dtype=torch.float32)
184-
grid = (triton.cdiv(M, 64), triton.cdiv(N, 64))
184+
grid = lambda meta: (triton.cdiv(M, meta['BLOCK_M']),
185+
triton.cdiv(N, meta['BLOCK_N']))
185186
_pairwise_dot_kernel[grid](
186187
x,
187188
y,
@@ -201,7 +202,8 @@ def _triton_pairwise_distances(
201202
x_norm = (x * x).sum(dim=1).float()
202203
y_norm = (y * y).sum(dim=1).float()
203204
out = torch.empty((M, N), device=x.device, dtype=torch.float32)
204-
grid = (triton.cdiv(M, 64), triton.cdiv(N, 64))
205+
grid = lambda meta: (triton.cdiv(M, meta['BLOCK_M']),
206+
triton.cdiv(N, meta['BLOCK_N']))
205207
_pairwise_distance_kernel[grid](
206208
x,
207209
y,

0 commit comments

Comments
 (0)