MCPcopy Create free account
hub / github.com/tdrussell/diffusion-pipe / forward

Method forward

models/sd3.py:229–249  ·  view source on GitHub ↗
(self, inputs)

Source from the content-addressed store, hash-verified

227
228 @torch.autocast('cuda', dtype=AUTOCAST_DTYPE)
229 def forward(self, inputs):
230 hidden_states, temb, latent_size, *_ = inputs
231 height = latent_size[0].item()
232 width = latent_size[1].item()
233
234 hidden_states = self.norm_out(hidden_states, temb)
235 hidden_states = self.proj_out(hidden_states)
236
237 # unpatchify
238 patch_size = self.config.patch_size
239 height = height // patch_size
240 width = width // patch_size
241
242 hidden_states = hidden_states.reshape(
243 shape=(hidden_states.shape[0], height, width, patch_size, patch_size, self.out_channels)
244 )
245 hidden_states = torch.einsum("nhwpqc->nchpwq", hidden_states)
246 output = hidden_states.reshape(
247 shape=(hidden_states.shape[0], self.out_channels, height * patch_size, width * patch_size)
248 )
249 return output

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected