Skip to content

Commit

Permalink
Refine mt5 (#410)
Browse files Browse the repository at this point in the history
* refine global_set of position_bias

* reformat
  • Loading branch information
xiezipeng-ML committed Oct 28, 2022
1 parent 9a4af26 commit b3c5ba2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion projects/MT5/layers/attention_layer.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,8 +217,8 @@ def forward(
position_bias = position_bias[:, :, -hidden_states.size(1) :, :]

position_bias = position_bias + (1 - attention_mask) * -1000
position_bias = position_bias.to_global(placement=attention_scores.placement)

position_bias = position_bias.to_global(placement=attention_scores.placement)
attention_scores = attention_scores + position_bias

if attention_mask is not None:
Expand Down
2 changes: 1 addition & 1 deletion projects/T5/models/attention.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,8 +224,8 @@ def forward(
position_bias = position_bias[:, :, -hidden_states.size(1) :, :]

position_bias = position_bias + (1 - attention_mask) * -1000
position_bias = position_bias.to_global(placement=attention_scores.placement)

position_bias = position_bias.to_global(placement=attention_scores.placement)
attention_scores = attention_scores + position_bias

# [S(0), S(1)] x [S(0), B] = [S(0), S(1)]
Expand Down

0 comments on commit b3c5ba2

Please sign in to comment.