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

Method __init__

sat/sgm/modules/diffusionmodules/openaimodel.py:177–202  ·  view source on GitHub ↗
(self, channels, use_conv, dims=2, out_channels=None, padding=1, third_down=False)

Source from the content-addressed store, hash-verified

175 """
176
177 def __init__(self, channels, use_conv, dims=2, out_channels=None, padding=1, third_down=False):
178 super().__init__()
179 self.channels = channels
180 self.out_channels = out_channels or channels
181 self.use_conv = use_conv
182 self.dims = dims
183 stride = 2 if dims != 3 else ((1, 2, 2) if not third_down else (2, 2, 2))
184 if use_conv:
185 print(f"Building a Downsample layer with {dims} dims.")
186 print(
187 f" --> settings are: \n in-chn: {self.channels}, out-chn: {self.out_channels}, "
188 f"kernel-size: 3, stride: {stride}, padding: {padding}"
189 )
190 if dims == 3:
191 print(f" --> Downsampling third axis (time): {third_down}")
192 self.op = conv_nd(
193 dims,
194 self.channels,
195 self.out_channels,
196 3,
197 stride=stride,
198 padding=padding,
199 )
200 else:
201 assert self.channels == self.out_channels
202 self.op = avg_pool_nd(dims, kernel_size=stride, stride=stride)
203
204 def forward(self, x):
205 assert x.shape[1] == self.channels

Callers

nothing calls this directly

Calls 4

conv_ndFunction · 0.85
avg_pool_ndFunction · 0.85
printFunction · 0.50
__init__Method · 0.45

Tested by

no test coverage detected