Text Generation
Transformers
PyTorch
Italian
mpt
ipt
alibi
text-generation-inference
text generation
custom_code
ipt-350m / custom_embedding.py
efederici's picture
Update custom_embedding.py
825136e
Raw
History Blame Contribute Delete
292 Bytes
import torch.nn as nn
import torch.nn.functional as F
from torch import Tensor
class SharedEmbedding(nn.Embedding):
def forward(self, input: Tensor, unembed: bool=False) -> Tensor:
if unembed:
return F.linear(input, self.weight)
return super().forward(input)