{"record":{"id":"d1bdf4cdd6f988b9","repo":"open-mmlab/mmdetection","slug":"kernel-kernel-is-not-supported-in-matrix-nms","errorCode":null,"errorMessage":"{kernel} kernel is not supported in matrix nms!","messagePattern":"(.+?) kernel is not supported in matrix nms!","errorType":"exception","errorClass":"NotImplementedError","httpStatus":null,"severity":"error","filePath":"mmdet/models/layers/matrix_nms.py","lineNumber":96,"sourceCode":"\n    # IoU compensation\n    compensate_iou, _ = (iou_matrix * label_matrix).max(0)\n    compensate_iou = compensate_iou.expand(num_masks,\n                                           num_masks).transpose(1, 0)\n\n    # IoU decay\n    decay_iou = iou_matrix * label_matrix\n\n    # Calculate the decay_coefficient\n    if kernel == 'gaussian':\n        decay_matrix = torch.exp(-1 * sigma * (decay_iou**2))\n        compensate_matrix = torch.exp(-1 * sigma * (compensate_iou**2))\n        decay_coefficient, _ = (decay_matrix / compensate_matrix).min(0)\n    elif kernel == 'linear':\n        decay_matrix = (1 - decay_iou) / (1 - compensate_iou)\n        decay_coefficient, _ = decay_matrix.min(0)\n    else:\n        raise NotImplementedError(\n            f'{kernel} kernel is not supported in matrix nms!')\n    # update the score.\n    scores = scores * decay_coefficient\n\n    if filter_thr > 0:\n        keep = scores >= filter_thr\n        keep_inds = keep_inds[keep]\n        if not keep.any():\n            return scores.new_zeros(0), labels.new_zeros(0), masks.new_zeros(\n                0, *masks.shape[-2:]), labels.new_zeros(0)\n        masks = masks[keep]\n        scores = scores[keep]\n        labels = labels[keep]\n\n    # sort and keep top max_num\n    scores, sort_inds = torch.sort(scores, descending=True)\n    keep_inds = keep_inds[sort_inds]\n    if max_num > 0 and len(sort_inds) > max_num:","sourceCodeStart":78,"sourceCodeEnd":114,"githubUrl":"https://github.com/open-mmlab/mmdetection/blob/cfd5d3a985b0249de009b67d04f37263e11cdf3d/mmdet/models/layers/matrix_nms.py#L78-L114","documentation":"Raised by mask_matrix_nms in mmdet when the `kernel` argument is neither 'gaussian' nor 'linear'. The kernel controls how overlapping mask IoUs decay the confidence scores of suppressed instances; any other string falls into the else-branch and raises NotImplementedError.","triggerScenarios":"Calling mask_matrix_nms(..., kernel='exp') or passing a typo like 'gaussion'/'Linear' from a config (e.g. MatrixNms with kernel='lnear') or calling _predict_by_feat_single of a mask head whose matrix_nms cfg sets an unsupported kernel.","commonSituations":"Config typos in MatrixNms kernel; copy-pasting configs from other repos that use different kernel names; assuming arbitrary kernel functions are supported.","solutions":["Set kernel to 'gaussian' or 'linear' in the MatrixNms / mask_matrix_nms config","Fix typos: 'gaussion' -> 'gaussian', 'linear' vs 'linea'","If a custom kernel is needed, subclass and override mask_matrix_nms to add it"],"exampleFix":"// before\nmatrix_nms_cfg=dict(type='MatrixNms', kernel='exp')\n// after\nmatrix_nms_cfg=dict(type='MatrixNms', kernel='gaussian')","handlingStrategy":"validation","validationCode":"assert kernel in ('gaussian', 'linear'), f'unsupported kernel: {kernel}'","typeGuard":null,"tryCatchPattern":"try: out = mask_matrix_nms(..., kernel=kernel)\nexcept NotImplementedError: out = mask_matrix_nms(..., kernel='gaussian')","preventionTips":["Validate kernel against the supported set before calling","Use config linting for MatrixNms blocks"],"tags":["mmdet","nms","config","not-implemented"],"backgroundTag":"invalid-argument-value","analyzedSha":"cfd5d3a985b0249de009b67d04f37263e11cdf3d","analyzedAt":"2026-08-27T20:54:20.183Z","schemaVersion":2},"datasetVersion":"2026-08-28T00:17:15.603Z"}