(self,
num_layers,
vocab_size,
hidden_size,
num_attention_heads,
embedding_dropout_prob,
attention_dropout_prob,
output_dropout_prob,
max_sequence_length,
max_memory_length,
checkpoint_activations,
checkpoint_num_layers=1,
parallel_output=True,
output_predict=True
)
| 141 | """ |
| 142 | |
| 143 | def __init__(self, |
| 144 | num_layers, |
| 145 | vocab_size, |
| 146 | hidden_size, |
| 147 | num_attention_heads, |
| 148 | embedding_dropout_prob, |
| 149 | attention_dropout_prob, |
| 150 | output_dropout_prob, |
| 151 | max_sequence_length, |
| 152 | max_memory_length, |
| 153 | checkpoint_activations, |
| 154 | checkpoint_num_layers=1, |
| 155 | parallel_output=True, |
| 156 | output_predict=True |
| 157 | ): |
| 158 | super(EncoderDecoder, self).__init__() |
| 159 | |
| 160 | self.parallel_output = parallel_output |
| 161 | self.output_predict = output_predict |
| 162 | |
| 163 | init_method = init_method_normal(std=0.02) |
| 164 | |
| 165 | # Word embeddings (parallel). |
| 166 | self.word_embeddings = mpu.VocabParallelEmbedding( |
| 167 | vocab_size, hidden_size, init_method=init_method) |
| 168 | |
| 169 | # Transformer |
| 170 | self.encoder = mpu.GPT2ParallelTransformer(num_layers, |
| 171 | hidden_size, |
| 172 | num_attention_heads, |
| 173 | max_sequence_length, |
| 174 | max_memory_length, |
| 175 | embedding_dropout_prob, |
| 176 | attention_dropout_prob, |
| 177 | output_dropout_prob, |
| 178 | checkpoint_activations, |
| 179 | checkpoint_num_layers) |
| 180 | self.decoder = mpu.GPT2ParallelTransformer(num_layers, |
| 181 | hidden_size, |
| 182 | num_attention_heads, |
| 183 | max_sequence_length, |
| 184 | max_memory_length, |
| 185 | embedding_dropout_prob, |
| 186 | attention_dropout_prob, |
| 187 | output_dropout_prob, |
| 188 | checkpoint_activations, |
| 189 | checkpoint_num_layers, |
| 190 | use_decoder_layer=True) |
| 191 | |
| 192 | def forward(self, source_ids, target_ids, source_position_ids, target_position_ids, source_mask, target_mask): |
| 193 | # Embeddings. |
nothing calls this directly
no test coverage detected