(self, config: ChatGLMConfig, device=None)
| 964 | """Language model embeddings.""" |
| 965 | |
| 966 | def __init__(self, config: ChatGLMConfig, device=None): |
| 967 | super(Embedding, self).__init__() |
| 968 | |
| 969 | self.hidden_size = config.hidden_size |
| 970 | # Word embeddings (parallel). |
| 971 | self.word_embeddings = nn.Embedding( |
| 972 | config.padded_vocab_size, |
| 973 | self.hidden_size, |
| 974 | dtype=config.torch_dtype, |
| 975 | device=device |
| 976 | ) |
| 977 | self.fp32_residual_connection = config.fp32_residual_connection |
| 978 | |
| 979 | def forward(self, input_ids): |
| 980 | # Embeddings. |