[Cherry-picked 0.9] Ignore return_complex when returning real-valued tensor in spectrogram. #1551
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In 0.9.0, we are adding
return_complex=False
to spectrogram operation, so that users can choose whether they receive the resulting complex-valued tensor in pseudo complex tensor (real dtype with an extra dimension for real/imaginary parts) or native complex tensor (torch.cfloat / torch.cdouble).Spectrogram operation returns raw, complex-valued tensor only when
power=None
. Ifpower
has some number, it returns the corresponding norm of the raw complex element. (such as power spectrogram) In this case, the value is always represented with real type, and there is no need to represent them in complex number.The current version (0.9-RC1) checks if
return_complex=True
whenpower is not non
. However, this does not align well with the use case. Users expecting power-spectrogram should not worry about thisreturn_complex
argument, which has its purpose in a different operation mode ofspectrogram
op. Also in #1549, I am switching the default value ofreturn_complex
toTrue
and this means that by default, users who want power spectrogram has to providereturn_complex=False
additionally. This is totally unnecessary and avoidable. Therefore we should only care about the value ofreturn_complex
, whenpower=None
in spectrogram op.