Skip to content

Commit a7b645d

Browse files
Copy the indptr to cpu to avoid GPU sync in the loop
1 parent 46e8249 commit a7b645d

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

gsplat/rendering.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,11 +500,12 @@ def reshape_view(C: int, world_view: torch.Tensor, N_world: list) -> torch.Tenso
500500

501501
# Compute dirs in B*C steps to avoid many-to-one indexing of cameras in backward pass
502502
dirs = torch.empty((nnz, 3), dtype=means.dtype, device=device)
503+
indptr_cpu = indptr.cpu()
503504
for b_idx in range(B):
504505
for c_idx in range(C):
505506
bc_idx = b_idx * C + c_idx
506-
start_idx = indptr[bc_idx].item()
507-
end_idx = indptr[bc_idx + 1].item()
507+
start_idx = indptr_cpu[bc_idx].item()
508+
end_idx = indptr_cpu[bc_idx + 1].item()
508509
if start_idx == end_idx:
509510
continue
510511

0 commit comments

Comments
 (0)