Skip to content

Commit d14deb8

Browse files
author
Dan-Flores
committed
assert contiguity with channels_last
1 parent ee2285e commit d14deb8

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

test/test_encoders.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -641,13 +641,13 @@ def test_contiguity(self, method, tmp_path):
641641
).contiguous()
642642
assert contiguous_frames.is_contiguous()
643643

644-
# Create non-contiguous frames by permuting, calling contiguous to update memory layout,
645-
# then permuting back to the initial order
644+
# Permute NCHW to NHWC, then update the memory layout, then permute back
646645
non_contiguous_frames = (
647-
contiguous_frames.permute(0, 3, 2, 1).contiguous().permute(0, 3, 2, 1)
646+
contiguous_frames.permute(0, 2, 3, 1).contiguous().permute(0, 3, 1, 2)
648647
)
649648
assert non_contiguous_frames.stride() != contiguous_frames.stride()
650649
assert not non_contiguous_frames.is_contiguous()
650+
assert non_contiguous_frames.is_contiguous(memory_format=torch.channels_last)
651651

652652
torch.testing.assert_close(
653653
contiguous_frames, non_contiguous_frames, rtol=0, atol=0

0 commit comments

Comments
 (0)