Skip to content

Commit

Permalink
Refactor implementation of F.compute_deltas (pytorch#1423)
Browse files Browse the repository at this point in the history
  • Loading branch information
yoyolicoris authored Apr 5, 2021
1 parent e964f93 commit 8d2eeb1
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions torchaudio/functional/functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@ def compute_deltas(

# pack batch
shape = specgram.size()
specgram = specgram.reshape(1, -1, shape[-1])
specgram = specgram.reshape(-1, 1, shape[-1])

assert win_length >= 3

Expand All @@ -804,9 +804,9 @@ def compute_deltas(

specgram = torch.nn.functional.pad(specgram, (n, n), mode=mode)

kernel = torch.arange(-n, n + 1, 1, device=device, dtype=dtype).repeat(specgram.shape[1], 1, 1)
kernel = torch.arange(-n, n + 1, 1, device=device, dtype=dtype).view(1, 1, -1)

output = torch.nn.functional.conv1d(specgram, kernel, groups=specgram.shape[1]) / denom
output = torch.nn.functional.conv1d(specgram, kernel) / denom

# unpack batch
output = output.reshape(shape)
Expand Down

0 comments on commit 8d2eeb1

Please sign in to comment.