Skip to content
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

Avoid torch.jit.isinstance to support torch.compile(MFCC(), fullgraph=True) #3876

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions src/torchaudio/functional/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,14 @@ def inverse_spectrogram(

def _get_spec_norms(normalized: Union[str, bool]):
frame_length_norm, window_norm = False, False
if torch.jit.isinstance(normalized, str):
if isinstance(normalized, str):
if normalized not in ["frame_length", "window"]:
raise ValueError("Invalid normalized parameter: {}".format(normalized))
if normalized == "frame_length":
frame_length_norm = True
elif normalized == "window":
window_norm = True
elif torch.jit.isinstance(normalized, bool):
elif isinstance(normalized, bool):
if normalized:
window_norm = True
else:
Expand Down
4 changes: 4 additions & 0 deletions test/torchaudio_unittest/transforms/transforms_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,10 @@ def test_compute_deltas_twochannel(self):
assert computed.shape == expected.shape, (computed.shape, expected.shape)
self.assertEqual(computed, expected, atol=1e-6, rtol=1e-8)

def test_mfcc_compile_fullgraph(self):
# test that MFCC does not use language features not supported by torch.compile
torch.compile(MFCC(), fullgraph=True)


class SmokeTest(common_utils.TorchaudioTestCase):
def test_spectrogram(self):
Expand Down