MCPcopy Create free account
hub / github.com/OpenDriveLab/ReSim / TimestepEmbedSequential

Class TimestepEmbedSequential

sat/sgm/modules/diffusionmodules/openaimodel.py:80–116  ·  view source on GitHub ↗

A sequential module that passes timestep embeddings to the children that support it as an extra input.

Source from the content-addressed store, hash-verified

78
79
80class TimestepEmbedSequential(nn.Sequential, TimestepBlock):
81 """
82 A sequential module that passes timestep embeddings to the children that
83 support it as an extra input.
84 """
85
86 def forward(
87 self,
88 x: th.Tensor,
89 emb: th.Tensor,
90 context: Optional[th.Tensor] = None,
91 image_only_indicator: Optional[th.Tensor] = None,
92 time_context: Optional[int] = None,
93 num_video_frames: Optional[int] = None,
94 ):
95 from ...modules.diffusionmodules.video_model import VideoResBlock
96
97 for layer in self:
98 module = layer
99
100 if isinstance(module, TimestepBlock) and not isinstance(module, VideoResBlock):
101 x = layer(x, emb)
102 elif isinstance(module, VideoResBlock):
103 x = layer(x, emb, num_video_frames, image_only_indicator)
104 elif isinstance(module, SpatialVideoTransformer):
105 x = layer(
106 x,
107 context,
108 time_context,
109 num_video_frames,
110 image_only_indicator,
111 )
112 elif isinstance(module, SpatialTransformer):
113 x = layer(x, context)
114 else:
115 x = layer(x)
116 return x
117
118
119class Upsample(nn.Module):

Callers 3

__init__Method · 0.85
__init__Method · 0.85
__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected