open-mmlab/mmdetection · error · NotImplementedError

_forward function (namely 'tensor' mode) is not supported no

Error message

_forward function (namely 'tensor' mode) is not supported now

What it means

BaseMot deliberately does not implement _forward (tensor mode); MOT models only support loss and predict. Any forward call with mode='tensor' hits this NotImplementedError.

Source

Thrown at mmdet/models/mot/base.py:146

        pass

    def _forward(self,
                 inputs: Dict[str, Tensor],
                 data_samples: OptTrackSampleList = None,
                 **kwargs):
        """Network forward process. Usually includes backbone, neck and head
        forward without any post-processing.

         Args:
            inputs (Dict[str, Tensor]): of shape (N, T, C, H, W).
            data_samples (List[:obj:`TrackDataSample`], optional): The
                Data Samples. It usually includes information such as
                `gt_instance`.

        Returns:
            tuple[list]: A tuple of features from ``head`` forward.
        """
        raise NotImplementedError(
            "_forward function (namely 'tensor' mode) is not supported now")

View on GitHub (pinned to cfd5d3a985)

Solutions

  1. Use mode='predict' instead of mode='tensor' for inference
  2. For feature extraction or deployment, use the underlying detector submodule directly (e.g. model.detector) rather than the MOT wrapper

Example fix

# before
feats = model(imgs, mode='tensor')
# after
results = model(imgs, data_samples, mode='predict')
Defensive patterns

Strategy: validation

Validate before calling

from mmdet.models.mot.base import BaseMot
if isinstance(model, BaseSort):  # SORT family supports only loss/predict
    assert mode != 'tensor'

Type guard

def supports_tensor_mode(model) -> bool: return not isinstance(getattr(model, 'loss', None).__self__, __import__('mmdet.models.mot', fromlist=['base']).BaseSort)

Prevention

When it happens

Trigger: Calling model(inputs, data_samples, mode='tensor') on a MOT model, or tooling (e.g. export scripts, ONNX tools, feature extraction) that defaults to tensor mode.

Common situations: Trying to export a tracking model to ONNX/TensorRT; using extract-feat style scripts from 1.x mmdet; generic wrappers that call _forward directly.

Related errors


AI-assisted analysis of open-mmlab/mmdetection@cfd5d3a985 (2026-08-27). Data as JSON: /api/errors/27dfb92773ad05e8. Report an issue: GitHub.