Skip to content
Open
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
5 changes: 4 additions & 1 deletion fairseq/models/wav2vec/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import math
import torch.nn.functional as F
import torch


def pad_to_multiple(x, multiple, dim=-1, value=0):
Expand All @@ -14,7 +15,9 @@ def pad_to_multiple(x, multiple, dim=-1, value=0):
tsz = x.size(dim)
m = tsz / multiple
remainder = math.ceil(m) * multiple - tsz
if m.is_integer():
if isinstance(m, torch.Tensor):
m = m.item() # Convert tensor to Python float
if isinstance(m, float) and m.is_integer():
return x, 0
pad_offset = (0,) * (-1 - dim) * 2

Expand Down