Skip to content

Commit 9756650

Browse files
vfdev-5NicolasHug
andauthored
Fix warning raised by torch.meshgrid on missing indexing (#8689)
Co-authored-by: Nicolas Hug <[email protected]>
1 parent acbfd8d commit 9756650

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

references/depth/stereo/utils/losses.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def make_gaussian_kernel(kernel_size: int, sigma: float) -> torch.Tensor:
1313
y = torch.arange(kernel_size, dtype=torch.float32)
1414
x = x - (kernel_size - 1) / 2
1515
y = y - (kernel_size - 1) / 2
16-
x, y = torch.meshgrid(x, y)
16+
x, y = torch.meshgrid(x, y, indexing="ij")
1717
grid = (x**2 + y**2) / (2 * sigma**2)
1818
kernel = torch.exp(-grid)
1919
kernel = kernel / kernel.sum()

torchvision/models/maxvit.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def _make_block_input_shapes(input_size: Tuple[int, int], n_blocks: int) -> List
4040

4141

4242
def _get_relative_position_index(height: int, width: int) -> torch.Tensor:
43-
coords = torch.stack(torch.meshgrid([torch.arange(height), torch.arange(width)]))
43+
coords = torch.stack(torch.meshgrid([torch.arange(height), torch.arange(width)], indexing="ij"))
4444
coords_flat = torch.flatten(coords, 1)
4545
relative_coords = coords_flat[:, :, None] - coords_flat[:, None, :]
4646
relative_coords = relative_coords.permute(1, 2, 0).contiguous()

0 commit comments

Comments
 (0)