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

Method forward

diffsynth/models/wan_video_image_encoder.py:122–147  ·  view source on GitHub ↗

ids: [B, L] of torch.LongTensor.

(self, ids)

Source from the content-addressed store, hash-verified

120 self.norm = nn.LayerNorm(dim, eps=eps)
121
122 def forward(self, ids):
123 """
124 ids: [B, L] of torch.LongTensor.
125 """
126 b, s = ids.shape
127 mask = ids.ne(self.pad_id).long()
128
129 # embeddings
130 x = self.token_embedding(ids) + \
131 self.type_embedding(torch.zeros_like(ids)) + \
132 self.pos_embedding(self.pad_id + torch.cumsum(mask, dim=1) * mask)
133 if self.post_norm:
134 x = self.norm(x)
135 x = self.dropout(x)
136
137 # blocks
138 mask = torch.where(
139 mask.view(b, 1, 1, s).gt(0), 0.0,
140 torch.finfo(x.dtype).min)
141 for block in self.blocks:
142 x = block(x, mask)
143
144 # output
145 if not self.post_norm:
146 x = self.norm(x)
147 return x
148
149
150def xlm_roberta_large(pretrained=False,

Callers

nothing calls this directly

Calls 1

normMethod · 0.80

Tested by

no test coverage detected