File size: 723 Bytes
7b6f2cc
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# Derived from PFN PLaMo; see docs/LICENSING.md.
import enum
import math
import warnings
from typing import Any, Dict, List, Literal, NamedTuple, Optional, Tuple, Union

import torch
from torch import nn
from torch.nn import functional as F
from transformers import GenerationMixin, PretrainedConfig, PreTrainedModel
from transformers.cache_utils import DynamicCache
from transformers.modeling_outputs import BaseModelOutputWithPast, CausalLMOutputWithPast


class LuxferEmbedding(nn.Embedding):
    def forward(self, x: torch.Tensor) -> torch.Tensor:
        y = super().forward(x)
        return y * (self.embedding_dim**0.5)

# Legacy source aliases; canonical public names use Luxfer.
Plamo3Embedding = LuxferEmbedding