lgcharpe commited on
Commit
1002007
1 Parent(s): bef6523

Update modeling_norbert.py

Browse files
Files changed (1) hide show
  1. modeling_norbert.py +3 -3
modeling_norbert.py CHANGED
@@ -156,7 +156,7 @@ class Attention(nn.Module):
156
  - torch.arange(config.max_position_embeddings, dtype=torch.long).unsqueeze(0)
157
  position_indices = self.make_log_bucket_position(position_indices, config.position_bucket_size, config.max_position_embeddings)
158
  position_indices = config.position_bucket_size - 1 + position_indices
159
- self.register_buffer("position_indices", position_indices, persistent=True)
160
 
161
  self.dropout = nn.Dropout(config.attention_probs_dropout_prob)
162
  self.scale = 1.0 / math.sqrt(3 * self.head_size)
@@ -186,8 +186,8 @@ class Attention(nn.Module):
186
  if self.position_indices.size(0) < query_len:
187
  position_indices = torch.arange(query_len, dtype=torch.long).unsqueeze(1) \
188
  - torch.arange(query_len, dtype=torch.long).unsqueeze(0)
189
- position_indices = self.make_log_bucket_position(position_indices, self.position_bucket_size, 512)
190
- position_indices = self.position_bucket_size - 1 + position_indices
191
  self.position_indices = position_indices.to(hidden_states.device)
192
 
193
  hidden_states = self.pre_layer_norm(hidden_states)
 
156
  - torch.arange(config.max_position_embeddings, dtype=torch.long).unsqueeze(0)
157
  position_indices = self.make_log_bucket_position(position_indices, config.position_bucket_size, config.max_position_embeddings)
158
  position_indices = config.position_bucket_size - 1 + position_indices
159
+ self.register_buffer("position_indices", position_indices, persistent=False)
160
 
161
  self.dropout = nn.Dropout(config.attention_probs_dropout_prob)
162
  self.scale = 1.0 / math.sqrt(3 * self.head_size)
 
186
  if self.position_indices.size(0) < query_len:
187
  position_indices = torch.arange(query_len, dtype=torch.long).unsqueeze(1) \
188
  - torch.arange(query_len, dtype=torch.long).unsqueeze(0)
189
+ position_indices = self.make_log_bucket_position(position_indices, self.config.position_bucket_size, 512)
190
+ position_indices = self.config.position_bucket_size - 1 + position_indices
191
  self.position_indices = position_indices.to(hidden_states.device)
192
 
193
  hidden_states = self.pre_layer_norm(hidden_states)