(self, config)
| 289 | """ |
| 290 | |
| 291 | def __init__(self, config): |
| 292 | super(BertEmbeddings, self).__init__() |
| 293 | self.word_embeddings = nn.Embedding(config.vocab_size, config.hidden_size) |
| 294 | # self.word_embeddings = mpu.VocabParallelEmbedding( |
| 295 | # config.vocab_size, config.hidden_size, |
| 296 | # init_method=normal_init_method(mean=0.0, |
| 297 | # std=config.initializer_range)) |
| 298 | self.position_embeddings = nn.Embedding(config.max_position_embeddings, config.hidden_size) |
| 299 | self.token_type_embeddings = nn.Embedding(config.type_vocab_size, config.hidden_size) |
| 300 | |
| 301 | # self.LayerNorm is not snake-cased to stick with TensorFlow model variable name and be able to load |
| 302 | # any TensorFlow checkpoint file |
| 303 | self.fp32_layernorm = config.fp32_layernorm |
| 304 | self.fp32_embedding = config.fp32_embedding |
| 305 | self.fp32_tokentypes = config.fp32_tokentypes |
| 306 | self.LayerNorm = BertLayerNorm(config.hidden_size, eps=config.layernorm_epsilon) |
| 307 | self.dropout = nn.Dropout(config.hidden_dropout_prob) |
| 308 | |
| 309 | def forward(self, input_ids, token_type_ids=None): |
| 310 | seq_length = input_ids.size(1) |
nothing calls this directly
no test coverage detected