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

use model device for embedding extraction #10719

Closed
wants to merge 2 commits into from
Closed
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 nemo/collections/asr/models/clustering_diarizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ def _extract_embeddings(self, manifest_file: str, scale_idx: int, num_scales: in
self._speaker_model.eval()
self.time_stamps = {}

all_embs = torch.empty([0])
all_embs = torch.empty([0], device=self._speaker_model.device)
for test_batch in tqdm(
self._speaker_model.test_dataloader(),
desc=f'[{scale_idx+1}/{num_scales}] extract embeddings',
Expand All @@ -354,7 +354,7 @@ def _extract_embeddings(self, manifest_file: str, scale_idx: int, num_scales: in
_, embs = self._speaker_model.forward(input_signal=audio_signal, input_signal_length=audio_signal_len)
emb_shape = embs.shape[-1]
embs = embs.view(-1, emb_shape)
all_embs = torch.cat((all_embs, embs.cpu().detach()), dim=0)
all_embs = torch.cat((all_embs, embs.detach()), dim=0)
del test_batch

with open(manifest_file, 'r', encoding='utf-8') as manifest:
Expand Down
Loading