MCPcopy Create free account
hub / github.com/OpenDriveLab/OccNet / BEVFormerLayer

Class BEVFormerLayer

projects/mmdet3d_plugin/bevformer/modules/encoder.py:243–406  ·  view source on GitHub ↗

Implements decoder layer in DETR transformer. Args: attn_cfgs (list[`mmcv.ConfigDict`] | list[dict] | dict )): Configs for self_attention or cross_attention, the order should be consistent with it in `operation_order`. If it is a dict, it would be

Source from the content-addressed store, hash-verified

241 attn_cfgs (list[`mmcv.ConfigDict`] | list[dict] | dict )):
242 Configs for self_attention or cross_attention, the order
243 should be consistent with it in `operation_order`. If it is
244 a dict, it would be expand to the number of attention in
245 `operation_order`.
246 feedforward_channels (int): The hidden dimension for FFNs.
247 ffn_dropout (float): Probability of an element to be zeroed
248 in ffn. Default 0.0.
249 operation_order (tuple[str]): The execution order of operation
250 in transformer. Such as ('self_attn', 'norm', 'ffn', 'norm').
251 Default:None
252 act_cfg (dict): The activation config for FFNs. Default: `LN`
253 norm_cfg (dict): Config dict for normalization layer.
254 Default: `LN`.
255 ffn_num_fcs (int): The number of fully-connected layers in FFNs.
256 Default:2.
257 """
258
259 def __init__(self,
260 attn_cfgs,
261 feedforward_channels,
262 ffn_dropout=0.0,
263 operation_order=None,
264 act_cfg=dict(type='ReLU', inplace=True),
265 norm_cfg=dict(type='LN'),
266 ffn_num_fcs=2,
267 **kwargs):
268 super(BEVFormerLayer, self).__init__(
269 attn_cfgs=attn_cfgs,
270 feedforward_channels=feedforward_channels,
271 ffn_dropout=ffn_dropout,
272 operation_order=operation_order,
273 act_cfg=act_cfg,
274 norm_cfg=norm_cfg,
275 ffn_num_fcs=ffn_num_fcs,
276 **kwargs)
277 self.fp16_enabled = False
278 assert len(operation_order) == 6
279 assert set(operation_order) == set(
280 ['self_attn', 'norm', 'cross_attn', 'ffn'])
281
282 def forward(self,
283 query,
284 key=None,
285 value=None,
286 bev_pos=None,
287 query_pos=None,
288 key_pos=None,
289 attn_masks=None,
290 query_key_padding_mask=None,
291 key_padding_mask=None,
292 ref_2d=None,
293 ref_3d=None,
294 bev_h=None,
295 bev_w=None,
296 reference_points_cam=None,
297 mask=None,
298 spatial_shapes=None,
299 level_start_index=None,
300 prev_bev=None,

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected