Skip to content

Ensure correct encoding for non-contiguous WF #666

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 30, 2025

Conversation

NicolasHug
Copy link
Member

TSIA!

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Apr 29, 2025
TORCH_CHECK(wf.dim() == 2, "waveform must have 2 dimensions, got ", wf.dim());
return wf;
return wf.contiguous();
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirming that this is load-bearing: newly added test fails if we just return wf without calling contiguous().

@@ -1284,6 +1284,35 @@ def test_encode_to_tensor_long_output(self):

torch.testing.assert_close(self.decode(encoded_tensor), samples)

def test_contiguity(self):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you provide some narration in the test about what exactly we're testing? I'm afraid I'm not familiar enough with tensor manipulation to fully understand everything. For example, I'm surprised assert_close(contiguous_samples, non_contiguous_samples) passes when they have different strides.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

The strides have to do with the representation of the tensor in memory. But it's not what uniquely determines the values of a tensor. E.g. a 2D tensor

A B
C D

can be represented in memory as

A B C D

or as

A C B D

They'd have different strides, but equal values.

@NicolasHug NicolasHug merged commit d717d6c into pytorch:main Apr 30, 2025
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Meta Open Source bot.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants