From a7ac334806071235caec1692b10336d40735067f Mon Sep 17 00:00:00 2001 From: Yist Lin Date: Thu, 20 May 2021 10:44:18 +0800 Subject: [PATCH] fix concat problem when uttr is on cuda device --- modules/dvector.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/modules/dvector.py b/modules/dvector.py index 9b4bfa9..b574e12 100644 --- a/modules/dvector.py +++ b/modules/dvector.py @@ -55,9 +55,8 @@ def embed_utterance(self, utterance: Tensor) -> Tensor: # Pad to multiple of hop length hop_len = self.seg_len // 2 tgt_len = math.ceil(utterance.size(0) / hop_len) * hop_len - padded = torch.cat( - [utterance, torch.zeros(tgt_len - utterance.size(0), utterance.size(1))] - ) + zero_padding = torch.zeros(tgt_len - utterance.size(0), utterance.size(1)) + padded = torch.cat([utterance, zero_padding.to(utterance.device)]) segments = padded.unfold(0, self.seg_len, self.seg_len // 2) segments = segments.transpose(1, 2) # (batch, seg_len, mel_dim)