Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/torchaudio/transforms/_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
_get_sinc_resample_kernel,
_stretch_waveform,
)
from torch.utils.cpp_extension import ROCM_HOME

__all__ = []

Expand Down Expand Up @@ -495,7 +496,11 @@ def forward(self, melspec: Tensor) -> Tensor:
if self.n_mels != n_mels:
raise ValueError("Expected an input with {} mel bins. Found: {}".format(self.n_mels, n_mels))

specgram = torch.relu(torch.linalg.lstsq(self.fb.transpose(-1, -2)[None], melspec, driver=self.driver).solution)
if ROCM_HOME is not None:
solution = torch.linalg.pinv(self.fb.transpose(-1, -2)[None]) @ melspec
else:
solution = torch.linalg.lstsq(self.fb.transpose(-1, -2)[None], melspec, driver=self.driver).solution
specgram = torch.relu(solution)

# unpack batch
specgram = specgram.view(shape[:-2] + (freq, time))
Expand Down