[fix] fix issues/382 修复scaled_dot_product_attention方法不支持cpu、mps的问题
parent
4a1a9bec8a
commit
375c22ec42
|
|
@ -141,6 +141,7 @@ class Attention(nn.Module):
|
|||
self.resid_dropout = nn.Dropout(args.dropout)
|
||||
self.dropout = args.dropout
|
||||
self.flash = hasattr(torch.nn.functional, 'scaled_dot_product_attention') and args.flash_attn
|
||||
self.flash = hasattr(torch.nn.functional, 'scaled_dot_product_attention') and args.flash_attn and torch.cuda.is_available()
|
||||
# print("WARNING: using slow attention. Flash Attention requires PyTorch >= 2.0")
|
||||
|
||||
def forward(self,
|
||||
|
|
|
|||
Loading…
Reference in New Issue