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

Method forward

diffsynth/models/sd3_dit.py:351–378  ·  view source on GitHub ↗
(self, hidden_states, timestep, prompt_emb, pooled_prompt_emb, tiled=False, tile_size=128, tile_stride=64, use_gradient_checkpointing=False)

Source from the content-addressed store, hash-verified

349 return hidden_states
350
351 def forward(self, hidden_states, timestep, prompt_emb, pooled_prompt_emb, tiled=False, tile_size=128, tile_stride=64, use_gradient_checkpointing=False):
352 if tiled:
353 return self.tiled_forward(hidden_states, timestep, prompt_emb, pooled_prompt_emb, tile_size, tile_stride)
354 conditioning = self.time_embedder(timestep, hidden_states.dtype) + self.pooled_text_embedder(pooled_prompt_emb)
355 prompt_emb = self.context_embedder(prompt_emb)
356
357 height, width = hidden_states.shape[-2:]
358 hidden_states = self.pos_embedder(hidden_states)
359
360 def create_custom_forward(module):
361 def custom_forward(*inputs):
362 return module(*inputs)
363 return custom_forward
364
365 for block in self.blocks:
366 if self.training and use_gradient_checkpointing:
367 hidden_states, prompt_emb = torch.utils.checkpoint.checkpoint(
368 create_custom_forward(block),
369 hidden_states, prompt_emb, conditioning,
370 use_reentrant=False,
371 )
372 else:
373 hidden_states, prompt_emb = block(hidden_states, prompt_emb, conditioning)
374
375 hidden_states = self.norm_out(hidden_states, conditioning)
376 hidden_states = self.proj_out(hidden_states)
377 hidden_states = rearrange(hidden_states, "B (H W) (P Q C) -> B C (H P) (W Q)", P=2, Q=2, H=height//2, W=width//2)
378 return hidden_states
379
380 @staticmethod
381 def state_dict_converter():

Callers 1

tiled_forwardMethod · 0.95

Calls 2

tiled_forwardMethod · 0.95
create_custom_forwardFunction · 0.85

Tested by

no test coverage detected