MCPcopy Create free account
hub / github.com/VCIP-RGBD/DFormer / forward

Method forward

mmseg/models/utils/embed.py:176–197  ·  view source on GitHub ↗

Args: x (Tensor): Has shape (B, C, H, W). In most case, C is 3. Returns: tuple: Contains merged results and its spatial shape. - x (Tensor): Has shape (B, out_h * out_w, embed_dims) - out_size (tuple[int]): Spatial shape of x

(self, x)

Source from the content-addressed store, hash-verified

174 self.init_out_size = None
175
176 def forward(self, x):
177 """
178 Args:
179 x (Tensor): Has shape (B, C, H, W). In most case, C is 3.
180
181 Returns:
182 tuple: Contains merged results and its spatial shape.
183
184 - x (Tensor): Has shape (B, out_h * out_w, embed_dims)
185 - out_size (tuple[int]): Spatial shape of x, arrange as
186 (out_h, out_w).
187 """
188
189 if self.adap_padding:
190 x = self.adap_padding(x)
191
192 x = self.projection(x)
193 out_size = (x.shape[2], x.shape[3])
194 x = x.flatten(2).transpose(1, 2)
195 if self.norm is not None:
196 x = self.norm(x)
197 return x, out_size
198
199
200class PatchMerging(BaseModule):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected