Unverified Commit ccd78ffb authored by moto's avatar moto Committed by GitHub
Browse files

Warn if the input dtype to TimeStretch is not complex (#3695)

Addresses #3688 
parent 172260f9
...@@ -1066,6 +1066,13 @@ class TimeStretch(torch.nn.Module): ...@@ -1066,6 +1066,13 @@ class TimeStretch(torch.nn.Module):
Stretched spectrogram. The resulting tensor is of the corresponding complex dtype Stretched spectrogram. The resulting tensor is of the corresponding complex dtype
as the input spectrogram, and the number of frames is changed to ``ceil(num_frame / rate)``. as the input spectrogram, and the number of frames is changed to ``ceil(num_frame / rate)``.
""" """
if not torch.is_complex(complex_specgrams):
warnings.warn(
"The input to TimeStretch must be complex type. "
"Providing non-complex tensor produces invalid results.",
stacklevel=4,
)
if overriding_rate is None: if overriding_rate is None:
if self.fixed_rate is None: if self.fixed_rate is None:
raise ValueError("If no fixed_rate is specified, must pass a valid rate to the forward method.") raise ValueError("If no fixed_rate is specified, must pass a valid rate to the forward method.")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment