MCPcopy Index your code
hub / github.com/microsoft/TRELLIS / forward

Method forward

trellis/models/sparse_structure_flow.py:176–200  ·  view source on GitHub ↗
(self, x: torch.Tensor, t: torch.Tensor, cond: torch.Tensor)

Source from the content-addressed store, hash-verified

174 nn.init.constant_(self.out_layer.bias, 0)
175
176 def forward(self, x: torch.Tensor, t: torch.Tensor, cond: torch.Tensor) -> torch.Tensor:
177 assert [*x.shape] == [x.shape[0], self.in_channels, *[self.resolution] * 3], \
178 f"Input shape mismatch, got {x.shape}, expected {[x.shape[0], self.in_channels, *[self.resolution] * 3]}"
179
180 h = patchify(x, self.patch_size)
181 h = h.view(*h.shape[:2], -1).permute(0, 2, 1).contiguous()
182
183 h = self.input_layer(h)
184 h = h + self.pos_emb[None]
185 t_emb = self.t_embedder(t)
186 if self.share_mod:
187 t_emb = self.adaLN_modulation(t_emb)
188 t_emb = t_emb.type(self.dtype)
189 h = h.type(self.dtype)
190 cond = cond.type(self.dtype)
191 for block in self.blocks:
192 h = block(h, t_emb, cond)
193 h = h.type(x.dtype)
194 h = F.layer_norm(h, h.shape[-1:])
195 h = self.out_layer(h)
196
197 h = h.permute(0, 2, 1).view(h.shape[0], h.shape[2], *[self.resolution // self.patch_size] * 3)
198 h = unpatchify(h, self.patch_size).contiguous()
199
200 return h

Callers

nothing calls this directly

Calls 3

patchifyFunction · 0.85
unpatchifyFunction · 0.85
typeMethod · 0.80

Tested by

no test coverage detected