MCPcopy Create free account
hub / github.com/ADLab-AutoDrive/BEVFusion / SparseBasicBlock

Class SparseBasicBlock

mmdet3d/ops/sparse_block.py:67–120  ·  view source on GitHub ↗

Sparse basic block for PartA^2. Sparse basic block implemented with submanifold sparse convolution. Args: inplanes (int): inplanes of block. planes (int): planes of block. stride (int): stride of the first block. Default: 1 downsample (None | Module): down s

Source from the content-addressed store, hash-verified

65
66
67class SparseBasicBlock(BasicBlock, spconv.SparseModule):
68 """Sparse basic block for PartA^2.
69
70 Sparse basic block implemented with submanifold sparse convolution.
71
72 Args:
73 inplanes (int): inplanes of block.
74 planes (int): planes of block.
75 stride (int): stride of the first block. Default: 1
76 downsample (None | Module): down sample module for block.
77 conv_cfg (dict): dictionary to construct and config conv layer.
78 Default: None
79 norm_cfg (dict): dictionary to construct and config norm layer.
80 Default: dict(type='BN')
81 """
82
83 expansion = 1
84
85 def __init__(self,
86 inplanes,
87 planes,
88 stride=1,
89 downsample=None,
90 conv_cfg=None,
91 norm_cfg=None):
92 spconv.SparseModule.__init__(self)
93 BasicBlock.__init__(
94 self,
95 inplanes,
96 planes,
97 stride=stride,
98 downsample=downsample,
99 conv_cfg=conv_cfg,
100 norm_cfg=norm_cfg)
101
102 def forward(self, x):
103 identity = x.features
104
105 assert x.features.dim() == 2, f'x.features.dim()={x.features.dim()}'
106
107 out = self.conv1(x)
108 out.features = self.norm1(out.features)
109 out.features = self.relu(out.features)
110
111 out = self.conv2(out)
112 out.features = self.norm2(out.features)
113
114 if self.downsample is not None:
115 identity = self.downsample(x)
116
117 out.features += identity
118 out.features = self.relu(out.features)
119
120 return out
121
122
123def make_sparse_convmodule(in_channels,

Callers 3

make_encoder_layersMethod · 0.90
make_decoder_layersMethod · 0.90
test_SparseBasicBlockFunction · 0.90

Calls

no outgoing calls

Tested by 1

test_SparseBasicBlockFunction · 0.72