LongFormer inplace modification error
I keep getting this error “one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [12, 4096, 159]], which is output 0 of ViewBackward, is at version 1; expected version 0 instead”Here is the code where I specify the global attention mask I feed into longformer:attention_mask = mask_srccls_ids = clss.detach().cpu().data.numpy()global_attention_mask = torch.zeros(src.shape,dtype=torch.long,device=src.device)global_attention_mask_curr = global_attention_mask.clone()global_attention_mask_curr[:,cls_ids] = 1I realize that global_attention_mask_curr[:,cls_ids] = 1 is an inplace operation as I’m setting specific indices to 1s. However in the example, you do pretty much exactly the same thing. How do I get around this error. (Btw if I comment out global_attention_mask_curr[:,cls_ids] = 1, it trains just fine.)