Commit 21599119 authored by zhangwenwei's avatar zhangwenwei
Browse files

Merge branch 'master' of gitlab.sz.sensetime.com:open-mmlab/mmdet.3d into fix-train-runtime

parents 185ec6e8 343267ed
...@@ -8,7 +8,7 @@ from .. import builder ...@@ -8,7 +8,7 @@ from .. import builder
from .base import BaseDetector from .base import BaseDetector
@DETECTORS.register_module @DETECTORS.register_module()
class MVXTwoStageDetector(BaseDetector): class MVXTwoStageDetector(BaseDetector):
def __init__(self, def __init__(self,
......
...@@ -6,7 +6,7 @@ from mmdet.models import DETECTORS, TwoStageDetector ...@@ -6,7 +6,7 @@ from mmdet.models import DETECTORS, TwoStageDetector
from .. import builder from .. import builder
@DETECTORS.register_module @DETECTORS.register_module()
class PartA2(TwoStageDetector): class PartA2(TwoStageDetector):
def __init__(self, def __init__(self,
......
...@@ -6,7 +6,7 @@ from mmdet.models import DETECTORS, SingleStageDetector ...@@ -6,7 +6,7 @@ from mmdet.models import DETECTORS, SingleStageDetector
from .. import builder from .. import builder
@DETECTORS.register_module @DETECTORS.register_module()
class VoxelNet(SingleStageDetector): class VoxelNet(SingleStageDetector):
def __init__(self, def __init__(self,
...@@ -88,7 +88,7 @@ class VoxelNet(SingleStageDetector): ...@@ -88,7 +88,7 @@ class VoxelNet(SingleStageDetector):
return bbox_list return bbox_list
@DETECTORS.register_module @DETECTORS.register_module()
class DynamicVoxelNet(VoxelNet): class DynamicVoxelNet(VoxelNet):
def __init__(self, def __init__(self,
......
import torch import torch
import torch.nn as nn import torch.nn as nn
import torch.nn.functional as F import torch.nn.functional as F
from mmcv.cnn import xavier_init from mmcv.cnn import ConvModule, xavier_init
from mmdet.ops import ConvModule
from ..registry import FUSION_LAYERS from ..registry import FUSION_LAYERS
...@@ -96,7 +95,7 @@ def point_sample( ...@@ -96,7 +95,7 @@ def point_sample(
return point_features.squeeze().t() return point_features.squeeze().t()
@FUSION_LAYERS.register_module @FUSION_LAYERS.register_module()
class PointFusion(nn.Module): class PointFusion(nn.Module):
"""Fuse image features from fused single scale features """Fuse image features from fused single scale features
""" """
......
...@@ -4,7 +4,7 @@ from torch import nn ...@@ -4,7 +4,7 @@ from torch import nn
from ..registry import MIDDLE_ENCODERS from ..registry import MIDDLE_ENCODERS
@MIDDLE_ENCODERS.register_module @MIDDLE_ENCODERS.register_module()
class PointPillarsScatter(nn.Module): class PointPillarsScatter(nn.Module):
def __init__(self, in_channels, output_shape): def __init__(self, in_channels, output_shape):
......
import torch.nn as nn import torch.nn as nn
from mmcv.cnn import build_norm_layer
import mmdet3d.ops.spconv as spconv import mmdet3d.ops.spconv as spconv
from mmdet.ops import build_norm_layer
from ..registry import MIDDLE_ENCODERS from ..registry import MIDDLE_ENCODERS
@MIDDLE_ENCODERS.register_module @MIDDLE_ENCODERS.register_module()
class SparseEncoder(nn.Module): class SparseEncoder(nn.Module):
def __init__(self, def __init__(self,
......
import torch import torch
import torch.nn as nn import torch.nn as nn
from mmcv.cnn import build_norm_layer
import mmdet3d.ops.spconv as spconv import mmdet3d.ops.spconv as spconv
from mmdet3d.ops import SparseBasicBlock from mmdet3d.ops import SparseBasicBlock
from mmdet.ops import build_norm_layer
from ..registry import MIDDLE_ENCODERS from ..registry import MIDDLE_ENCODERS
@MIDDLE_ENCODERS.register_module @MIDDLE_ENCODERS.register_module()
class SparseUNet(nn.Module): class SparseUNet(nn.Module):
def __init__(self, def __init__(self,
......
...@@ -2,16 +2,15 @@ from functools import partial ...@@ -2,16 +2,15 @@ from functools import partial
import torch import torch
import torch.nn as nn import torch.nn as nn
from mmcv.cnn import constant_init, kaiming_init from mmcv.cnn import build_norm_layer, constant_init, kaiming_init
from torch.nn import Sequential from torch.nn import Sequential
from torch.nn.modules.batchnorm import _BatchNorm from torch.nn.modules.batchnorm import _BatchNorm
from mmdet.models import NECKS from mmdet.models import NECKS
from mmdet.ops import build_norm_layer
from .. import builder from .. import builder
@NECKS.register_module @NECKS.register_module()
class SECONDFPN(nn.Module): class SECONDFPN(nn.Module):
"""Compare with RPN, RPNV2 support arbitrary number of stage. """Compare with RPN, RPNV2 support arbitrary number of stage.
""" """
...@@ -64,7 +63,7 @@ class SECONDFPN(nn.Module): ...@@ -64,7 +63,7 @@ class SECONDFPN(nn.Module):
return [out] return [out]
@NECKS.register_module @NECKS.register_module()
class SECONDFusionFPN(SECONDFPN): class SECONDFusionFPN(SECONDFPN):
"""Compare with RPN, RPNV2 support arbitrary number of stage. """Compare with RPN, RPNV2 support arbitrary number of stage.
""" """
......
import torch import torch
from mmcv.cnn import build_norm_layer
from torch import nn from torch import nn
from mmdet3d.ops import DynamicScatter from mmdet3d.ops import DynamicScatter
from mmdet.ops import build_norm_layer
from ..registry import VOXEL_ENCODERS from ..registry import VOXEL_ENCODERS
from .utils import PFNLayer, get_paddings_indicator from .utils import PFNLayer, get_paddings_indicator
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class PillarFeatureNet(nn.Module): class PillarFeatureNet(nn.Module):
def __init__(self, def __init__(self,
...@@ -118,7 +118,7 @@ class PillarFeatureNet(nn.Module): ...@@ -118,7 +118,7 @@ class PillarFeatureNet(nn.Module):
return features.squeeze() return features.squeeze()
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class DynamicPillarFeatureNet(PillarFeatureNet): class DynamicPillarFeatureNet(PillarFeatureNet):
def __init__(self, def __init__(self,
...@@ -237,7 +237,7 @@ class DynamicPillarFeatureNet(PillarFeatureNet): ...@@ -237,7 +237,7 @@ class DynamicPillarFeatureNet(PillarFeatureNet):
return voxel_feats, voxel_coors return voxel_feats, voxel_coors
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class AlignedPillarFeatureNet(nn.Module): class AlignedPillarFeatureNet(nn.Module):
def __init__(self, def __init__(self,
......
import torch import torch
from mmcv.cnn import build_norm_layer
from torch import nn from torch import nn
from torch.nn import functional as F from torch.nn import functional as F
from mmdet.ops import build_norm_layer
class Empty(nn.Module): class Empty(nn.Module):
......
import torch import torch
from mmcv.cnn import build_norm_layer
from torch import nn from torch import nn
from torch.nn import functional as F from torch.nn import functional as F
from mmdet3d.ops import DynamicScatter from mmdet3d.ops import DynamicScatter
from mmdet.ops import build_norm_layer
from .. import builder from .. import builder
from ..registry import VOXEL_ENCODERS from ..registry import VOXEL_ENCODERS
from .utils import Empty, VFELayer, get_paddings_indicator from .utils import Empty, VFELayer, get_paddings_indicator
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class VoxelFeatureExtractor(nn.Module): class VoxelFeatureExtractor(nn.Module):
def __init__(self, def __init__(self,
...@@ -71,7 +71,7 @@ class VoxelFeatureExtractor(nn.Module): ...@@ -71,7 +71,7 @@ class VoxelFeatureExtractor(nn.Module):
return voxelwise return voxelwise
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class VoxelFeatureExtractorV2(nn.Module): class VoxelFeatureExtractorV2(nn.Module):
def __init__(self, def __init__(self,
...@@ -132,7 +132,7 @@ class VoxelFeatureExtractorV2(nn.Module): ...@@ -132,7 +132,7 @@ class VoxelFeatureExtractorV2(nn.Module):
return voxelwise return voxelwise
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class VoxelFeatureExtractorV3(nn.Module): class VoxelFeatureExtractorV3(nn.Module):
def __init__(self, def __init__(self,
...@@ -152,7 +152,7 @@ class VoxelFeatureExtractorV3(nn.Module): ...@@ -152,7 +152,7 @@ class VoxelFeatureExtractorV3(nn.Module):
return points_mean.contiguous() return points_mean.contiguous()
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class DynamicVFEV3(nn.Module): class DynamicVFEV3(nn.Module):
def __init__(self, def __init__(self,
...@@ -170,7 +170,7 @@ class DynamicVFEV3(nn.Module): ...@@ -170,7 +170,7 @@ class DynamicVFEV3(nn.Module):
return features, features_coors return features, features_coors
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class DynamicVFE(nn.Module): class DynamicVFE(nn.Module):
def __init__(self, def __init__(self,
...@@ -318,7 +318,7 @@ class DynamicVFE(nn.Module): ...@@ -318,7 +318,7 @@ class DynamicVFE(nn.Module):
return voxel_feats, voxel_coors return voxel_feats, voxel_coors
@VOXEL_ENCODERS.register_module @VOXEL_ENCODERS.register_module()
class HardVFE(nn.Module): class HardVFE(nn.Module):
def __init__(self, def __init__(self,
......
...@@ -13,7 +13,6 @@ __all__ = [ ...@@ -13,7 +13,6 @@ __all__ = [
'roi_align', 'roi_align',
'get_compiler_version', 'get_compiler_version',
'get_compiling_cuda_version', 'get_compiling_cuda_version',
'build_conv_layer',
'NaiveSyncBatchNorm1d', 'NaiveSyncBatchNorm1d',
'NaiveSyncBatchNorm2d', 'NaiveSyncBatchNorm2d',
'batched_nms', 'batched_nms',
......
import torch import torch
import torch.distributed as dist import torch.distributed as dist
import torch.nn as nn import torch.nn as nn
from mmcv.cnn import NORM_LAYERS
from torch.autograd.function import Function from torch.autograd.function import Function
from mmdet.ops.norm import norm_cfg
class AllReduce(Function): class AllReduce(Function):
...@@ -24,6 +23,7 @@ class AllReduce(Function): ...@@ -24,6 +23,7 @@ class AllReduce(Function):
return grad_output return grad_output
@NORM_LAYERS.register_module('naiveSyncBN1d')
class NaiveSyncBatchNorm1d(nn.BatchNorm1d): class NaiveSyncBatchNorm1d(nn.BatchNorm1d):
"""Syncronized Batch Normalization for 3D Tensors """Syncronized Batch Normalization for 3D Tensors
...@@ -68,6 +68,7 @@ class NaiveSyncBatchNorm1d(nn.BatchNorm1d): ...@@ -68,6 +68,7 @@ class NaiveSyncBatchNorm1d(nn.BatchNorm1d):
return input * scale + bias return input * scale + bias
@NORM_LAYERS.register_module('naiveSyncBN2d')
class NaiveSyncBatchNorm2d(nn.BatchNorm2d): class NaiveSyncBatchNorm2d(nn.BatchNorm2d):
"""Syncronized Batch Normalization for 4D Tensors """Syncronized Batch Normalization for 4D Tensors
...@@ -110,10 +111,3 @@ class NaiveSyncBatchNorm2d(nn.BatchNorm2d): ...@@ -110,10 +111,3 @@ class NaiveSyncBatchNorm2d(nn.BatchNorm2d):
scale = scale.reshape(1, -1, 1, 1) scale = scale.reshape(1, -1, 1, 1)
bias = bias.reshape(1, -1, 1, 1) bias = bias.reshape(1, -1, 1, 1)
return input * scale + bias return input * scale + bias
norm_cfg.update({
'BN1d': ('bn', nn.BatchNorm1d),
'naiveSyncBN2d': ('bn', NaiveSyncBatchNorm2d),
'naiveSyncBN1d': ('bn', NaiveSyncBatchNorm1d),
})
from mmcv.cnn import build_norm_layer
from torch import nn from torch import nn
import mmdet3d.ops.spconv as spconv import mmdet3d.ops.spconv as spconv
from mmdet.models.backbones.resnet import BasicBlock, Bottleneck from mmdet.models.backbones.resnet import BasicBlock, Bottleneck
from mmdet.ops import build_norm_layer
from mmdet.ops.conv import conv_cfg
conv_cfg.update({'SubMConv3d': spconv.SubMConv3d})
def conv3x3(in_planes, out_planes, stride=1, indice_key=None): def conv3x3(in_planes, out_planes, stride=1, indice_key=None):
......
...@@ -16,6 +16,7 @@ import math ...@@ -16,6 +16,7 @@ import math
import numpy as np import numpy as np
import torch import torch
from mmcv.cnn import CONV_LAYERS
from torch.nn import init from torch.nn import init
from torch.nn.parameter import Parameter from torch.nn.parameter import Parameter
...@@ -205,6 +206,7 @@ class SparseConvolution(SparseModule): ...@@ -205,6 +206,7 @@ class SparseConvolution(SparseModule):
return out_tensor return out_tensor
@CONV_LAYERS.register_module()
class SparseConv2d(SparseConvolution): class SparseConv2d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -230,6 +232,7 @@ class SparseConv2d(SparseConvolution): ...@@ -230,6 +232,7 @@ class SparseConv2d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConv3d(SparseConvolution): class SparseConv3d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -255,6 +258,7 @@ class SparseConv3d(SparseConvolution): ...@@ -255,6 +258,7 @@ class SparseConv3d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConv4d(SparseConvolution): class SparseConv4d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -280,6 +284,7 @@ class SparseConv4d(SparseConvolution): ...@@ -280,6 +284,7 @@ class SparseConv4d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConvTranspose2d(SparseConvolution): class SparseConvTranspose2d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -306,6 +311,7 @@ class SparseConvTranspose2d(SparseConvolution): ...@@ -306,6 +311,7 @@ class SparseConvTranspose2d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseConvTranspose3d(SparseConvolution): class SparseConvTranspose3d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -332,6 +338,7 @@ class SparseConvTranspose3d(SparseConvolution): ...@@ -332,6 +338,7 @@ class SparseConvTranspose3d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseInverseConv2d(SparseConvolution): class SparseInverseConv2d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -350,6 +357,7 @@ class SparseInverseConv2d(SparseConvolution): ...@@ -350,6 +357,7 @@ class SparseInverseConv2d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SparseInverseConv3d(SparseConvolution): class SparseInverseConv3d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -368,6 +376,7 @@ class SparseInverseConv3d(SparseConvolution): ...@@ -368,6 +376,7 @@ class SparseInverseConv3d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SubMConv2d(SparseConvolution): class SubMConv2d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -394,6 +403,7 @@ class SubMConv2d(SparseConvolution): ...@@ -394,6 +403,7 @@ class SubMConv2d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SubMConv3d(SparseConvolution): class SubMConv3d(SparseConvolution):
def __init__(self, def __init__(self,
...@@ -420,6 +430,7 @@ class SubMConv3d(SparseConvolution): ...@@ -420,6 +430,7 @@ class SubMConv3d(SparseConvolution):
indice_key=indice_key) indice_key=indice_key)
@CONV_LAYERS.register_module()
class SubMConv4d(SparseConvolution): class SubMConv4d(SparseConvolution):
def __init__(self, def __init__(self,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment