MCPcopy Create free account
hub / github.com/FunAudioLLM/SenseVoice / sequence_mask

Function sequence_mask

model.py:283–291  ·  view source on GitHub ↗
(lengths, maxlen=None, dtype=torch.float32, device=None)

Source from the content-addressed store, hash-verified

281
282
283def sequence_mask(lengths, maxlen=None, dtype=torch.float32, device=None):
284 if maxlen is None:
285 maxlen = lengths.max()
286 row_vector = torch.arange(0, maxlen, 1).to(lengths.device)
287 matrix = torch.unsqueeze(lengths, dim=-1)
288 mask = row_vector < matrix
289 mask = mask.detach()
290
291 return mask.type(dtype).to(device) if device is not None else mask.type(dtype)
292
293
294class EncoderLayerSANM(nn.Module):

Callers 2

export_rebuild_modelFunction · 0.85
forwardMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected