Skip to content

Commit a56f63a

Browse files
authored
Specify device for codebook indices creation (NVIDIA-NeMo#15405)
Bug: torch.arange always creates a tensor on cpu, but the FSQ might be moved to another device, crashing codes function when called (because of self.decode function: indices//self.dim_base_index...) Fix: just move to device when creating tensor. Signed-off-by: Ferdydh <ferdydh.hadiwijaya@tum.de>
1 parent 412706f commit a56f63a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

nemo/collections/tts/modules/audio_codec_modules.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1256,7 +1256,7 @@ def codes(self):
12561256
12571257
Note that the codebook entries are implicitly defined by the number of levels.
12581258
"""
1259-
indices = torch.arange(self.codebook_size)
1259+
indices = torch.arange(self.codebook_size, device=self.dim_base_index.device)
12601260
# [D, B, T]
12611261
indices = rearrange(indices, 'B -> 1 B 1')
12621262
# [B, D, T]

0 commit comments

Comments
 (0)