MCPcopy Create free account
hub / github.com/OpenImagingLab/FlashVSR / __init__

Method __init__

diffsynth/models/sdxl_text_encoder.py:45–64  ·  view source on GitHub ↗
(self, embed_dim=1280, vocab_size=49408, max_position_embeddings=77, num_encoder_layers=32, encoder_intermediate_size=5120)

Source from the content-addressed store, hash-verified

43
44class SDXLTextEncoder2(torch.nn.Module):
45 def __init__(self, embed_dim=1280, vocab_size=49408, max_position_embeddings=77, num_encoder_layers=32, encoder_intermediate_size=5120):
46 super().__init__()
47
48 # token_embedding
49 self.token_embedding = torch.nn.Embedding(vocab_size, embed_dim)
50
51 # position_embeds (This is a fixed tensor)
52 self.position_embeds = torch.nn.Parameter(torch.zeros(1, max_position_embeddings, embed_dim))
53
54 # encoders
55 self.encoders = torch.nn.ModuleList([CLIPEncoderLayer(embed_dim, encoder_intermediate_size, num_heads=20, head_dim=64, use_quick_gelu=False) for _ in range(num_encoder_layers)])
56
57 # attn_mask
58 self.attn_mask = self.attention_mask(max_position_embeddings)
59
60 # final_layer_norm
61 self.final_layer_norm = torch.nn.LayerNorm(embed_dim)
62
63 # text_projection
64 self.text_projection = torch.nn.Linear(embed_dim, embed_dim, bias=False)
65
66 def attention_mask(self, length):
67 mask = torch.empty(length, length)

Callers

nothing calls this directly

Calls 3

attention_maskMethod · 0.95
CLIPEncoderLayerClass · 0.85
__init__Method · 0.45

Tested by

no test coverage detected