Fix attn_mask bug in TransformerEncoderLayer (only affects speech_recognition example)
Summary:
Fixes
Pull Request resolved:
@@ -94,7 +94,11 @@ class TransformerEncoderLayer(nn.Module):
# TODO: to formally solve this problem, we need to change fairseq's
# MultiheadAttention. We will do this later on.
x, _ = self.self_attn(
- query=x, key=x, value=x, key_padding_mask=encoder_padding_mask
+ query=x,
+ key=x,
+ value=x,
+ key_padding_mask=encoder_padding_mask,
+ attn_mask=attn_mask,
)
x = F.dropout(x, p=self.dropout, training=self.training)
x = residual + x
