mirror of https://github.com/hpcaitech/ColossalAI
[shardformer] remove useless code (#5645)
parent
148506c828
commit
5d88ef1aaf
|
@ -58,20 +58,6 @@ class OPTPipelineForwards:
|
|||
under pipeline setting.
|
||||
"""
|
||||
|
||||
@staticmethod
|
||||
def _expand_mask(mask: torch.Tensor, dtype: torch.dtype, tgt_len: Optional[int] = None):
|
||||
"""
|
||||
Expands attention_mask from `[bsz, seq_len]` to `[bsz, 1, tgt_seq_len, src_seq_len]`.
|
||||
"""
|
||||
bsz, src_len = mask.size()
|
||||
tgt_len = tgt_len if tgt_len is not None else src_len
|
||||
|
||||
expanded_mask = mask[:, None, None, :].expand(bsz, 1, tgt_len, src_len).to(dtype)
|
||||
|
||||
inverted_mask = 1.0 - expanded_mask
|
||||
|
||||
return inverted_mask.masked_fill(inverted_mask.to(torch.bool), torch.finfo(dtype).min)
|
||||
|
||||
@staticmethod
|
||||
def opt_model_forward(
|
||||
self: OPTModel,
|
||||
|
|
Loading…
Reference in New Issue