Safetensors
mpt
custom_code
Ola_krutrim_optimized / custom_embedding.py
gosshh's picture
Upload 14 files
2221636 verified
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)