MCPcopy Create free account
hub / github.com/BorealisAI/scaleformer / __init__

Method __init__

utils/masking.py:38–44  ·  view source on GitHub ↗
(self, B, H, L, index, scores, device="cpu")

Source from the content-addressed store, hash-verified

36
37class ProbMask():
38 def __init__(self, B, H, L, index, scores, device="cpu"):
39 _mask = torch.ones(L, scores.shape[-1], dtype=torch.bool).to(device).triu(1)
40 _mask_ex = _mask[None, None, :].expand(B, H, L, scores.shape[-1])
41 indicator = _mask_ex[torch.arange(B)[:, None, None],
42 torch.arange(H)[None, :, None],
43 index, :].to(device)
44 self._mask = indicator.view(scores.shape).to(device)
45
46 @property
47 def mask(self):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected