-
Notifications
You must be signed in to change notification settings - Fork 217
Fix HFFT tests to use complex input tensors #1533
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6881,25 +6881,25 @@ public void Float64FFT() | |
| [TestOf(nameof(fft.hfft))] | ||
| public void Float32HFFT() | ||
| { | ||
| var input = torch.arange(4); | ||
| var input = torch.arange(4, complex64); | ||
| var output = fft.hfft(input); | ||
| Assert.Equal(6, output.shape[0]); | ||
| Assert.Equal(ScalarType.Float32, output.dtype); | ||
|
|
||
| var inverted = fft.ifft(output); | ||
| var inverted = fft.ihfft(output); | ||
| Assert.Equal(ScalarType.ComplexFloat32, inverted.dtype); | ||
| } | ||
|
|
||
| [Fact] | ||
| [TestOf(nameof(fft.hfft))] | ||
| public void Float64HFFT() | ||
| { | ||
| var input = torch.arange(4, float64); | ||
| var input = torch.arange(4, complex128); | ||
| var output = fft.hfft(input); | ||
| Assert.Equal(6, output.shape[0]); | ||
| Assert.Equal(ScalarType.Float64, output.dtype); | ||
|
|
||
| var inverted = fft.ifft(output); | ||
| var inverted = fft.ihfft(output); | ||
| Assert.Equal(ScalarType.ComplexFloat64, inverted.dtype); | ||
| } | ||
|
|
||
|
|
@@ -7142,10 +7142,10 @@ public void Float64RFFTN() | |
| [TestOf(nameof(fft.hfft2))] | ||
| public void Float32HFFT2() | ||
| { | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }); | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex64); | ||
| var output = fft.hfft2(input); | ||
| Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape); | ||
| Assert.Equal(input.dtype, output.dtype); | ||
| Assert.Equal(ScalarType.Float32, output.dtype); | ||
|
|
||
| var inverted = fft.ihfft2(output); | ||
| Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape); | ||
|
|
@@ -7156,26 +7156,26 @@ public void Float32HFFT2() | |
| [TestOf(nameof(fft.hfft2))] | ||
| public void Float64HFFT2() | ||
| { | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }, float64); | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex128); | ||
| var output = fft.hfft2(input); | ||
| Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape); | ||
| Assert.Equal(input.dtype, output.dtype); | ||
| Assert.Equal(ScalarType.Float64, output.dtype); | ||
|
|
||
| var inverted = fft.ihfft2(output); | ||
| Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape); | ||
| Assert.Equal(ScalarType.ComplexFloat64, inverted.dtype); | ||
| } | ||
|
|
||
| [Fact] | ||
| [TestOf(nameof(fft.hfft2))] | ||
| [TestOf(nameof(fft.hfftn))] | ||
| public void Float32HFFTN() | ||
| { | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }); | ||
| var output = fft.hfft2(input); | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex64); | ||
| var output = fft.hfftn(input); | ||
|
Comment on lines
7145
to
7174
|
||
| Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape); | ||
| Assert.Equal(input.dtype, output.dtype); | ||
| Assert.Equal(ScalarType.Float32, output.dtype); | ||
|
|
||
| var inverted = fft.ihfft2(output); | ||
| var inverted = fft.ihfftn(output); | ||
| Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape); | ||
| Assert.Equal(ScalarType.ComplexFloat32, inverted.dtype); | ||
| } | ||
|
|
@@ -7188,10 +7188,10 @@ public void Float64HFFTN() | |
|
|
||
| // TODO: Something in this test makes if fail on Windows / Release and MacOS / Release | ||
|
|
||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }, float64); | ||
| var input = torch.rand(new long[] { 5, 5, 5, 5 }, complex128); | ||
| var output = fft.hfftn(input); | ||
| Assert.Equal(new long[] { 5, 5, 5, 8 }, output.shape); | ||
| Assert.Equal(input.dtype, output.dtype); | ||
| Assert.Equal(ScalarType.Float64, output.dtype); | ||
|
|
||
| var inverted = fft.ihfftn(output); | ||
| Assert.Equal(new long[] { 5, 5, 5, 5 }, inverted.shape); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Float32HFFTnow uses complex input and is functionally identical to the existingComplexFloat32HFFTtest (and similarlyFloat64HFFTduplicatesComplexFloat64HFFTlater in this file). This introduces redundant coverage and makes the intent of the “Float32/Float64” naming unclear. Consider removing the duplicate tests or renaming/adjusting them so each case covers a distinct scenario (e.g., only keep the Complex* variants, or have one set validate round-trip/value behavior).