Skip to content

Commit

Permalink
coords_grid on device
Browse files Browse the repository at this point in the history
  • Loading branch information
magehrig committed Sep 28, 2021
1 parent e6e53c4 commit 0d123fd
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/utils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,8 @@ def bilinear_sampler(img, coords, mode='bilinear', mask=False):
return img


def coords_grid(batch, ht, wd):
coords = torch.meshgrid(torch.arange(ht), torch.arange(wd))
def coords_grid(batch, ht, wd, device):
coords = torch.meshgrid(torch.arange(ht, device=device), torch.arange(wd, device=device))
coords = torch.stack(coords[::-1], dim=0).float()
return coords[None].repeat(batch, 1, 1, 1)

Expand Down

0 comments on commit 0d123fd

Please sign in to comment.