(self, config: ChatGLMConfig, device=None)
| 617 | """Language model embeddings.""" |
| 618 | |
| 619 | def __init__(self, config: ChatGLMConfig, device=None): |
| 620 | super(Embedding, self).__init__() |
| 621 | |
| 622 | self.hidden_size = config.hidden_size |
| 623 | # Word embeddings (parallel). |
| 624 | self.word_embeddings = nn.Embedding( |
| 625 | config.padded_vocab_size, |
| 626 | self.hidden_size, |
| 627 | dtype=config.torch_dtype, |
| 628 | device=device |
| 629 | ) |
| 630 | self.fp32_residual_connection = config.fp32_residual_connection |
| 631 | |
| 632 | def forward(self, input_ids): |
| 633 | # Embeddings. |