Skip to content

inferer

Abstract base class for test-time inference strategies.

Classes:

  • Inferer –

    Base class for test-time inference strategies.

Inferer [source]

Base class for test-time inference strategies.

An Inferer decouples how a model is run at test time from the model itself. The model only knows how to map a batch of points to per-point logits; the Inferer decides whether that happens in a single forward pass, over cropped windows, tiled blocks, or repeated under augmentation, and how partial predictions are stitched back into one per-point output. This keeps evaluation code identical regardless of scene size or protocol.

Subclasses implement forward; __call__ delegates to it, mirroring torch.nn.Module. To use an inferer, call the instance directly:

inferer = SomeInferer(...)
logits = inferer(data, predictor=lambda d: model(d["pos"], d["pos"], d["batch"]))

data is a packed-batch dict (at minimum containing position and batch indices). predictor is any callable taking such a dict and returning per-point logits of shape \((N, C_\text{out})\). Inferers keep nothing of the scene, so one instance can be reused across scenes and wrapped by another inferer.

Inferers that draw random numbers take a seed. None follows the global generator, like the transforms do, so one torch.manual_seed (or seed_everything) seeds the whole evaluation. An int gives the inferer its own stream, offset by the number of calls the instance has made: successive calls (e.g. TTAInferer votes) draw different numbers, and a fresh instance replays the same sequence.

The softmax parameter controls whether partial predictions are converted to softmax probabilities before aggregation, and aggregate how they are combined:

Inferer softmax Aggregated quantity
SimpleInferer False predictor output as-is
SlidingWindowInferer True softmax probabilities per block ("max" / "vote" always)
KNNWindowInferer False raw logits ("mean"); always probabilities ("ema")
VoxelPartitionInferer False raw logits per pass
PotentialSphereInferer none always an EMA of softmax probabilities
TTAInferer False base output as-is
PartRefinementInferer none one-hot refined labels of the base output's argmax

When the input scene is empty (\(N = 0\)), inferers that never call the predictor return a \((0, 0)\) tensor (the channel count cannot be inferred without a predictor call); SimpleInferer and TTAInferer return whatever the predictor / base inferer produces for the empty input.

To add a custom strategy, subclass Inferer and implement forward:

from torch_pointcloud.inferers import Inferer

class MyInferer(Inferer):
    def forward(self, data, predictor):
        return predictor(data)

Methods:

  • forward –

    Run the inference strategy.

forward abstractmethod [source]

forward(
    data: Dict[str, Any],
    predictor: Callable[[Dict[str, Any]], Tensor],
) -> Tensor

Run the inference strategy.

Parameters:

  • data (Dict[str, Any]) –

    Packed-batch dict. Must contain pos and batch keys (the exact names are configurable on subclasses that expose pos_key / batch_key).

  • predictor (Callable[[Dict[str, Any]], Tensor]) –

    Callable taking a packed dict and returning per-point logits of shape \((N, C_\text{out})\).

Returns:

  • Tensor –

    Per-point output tensor of shape \((N, C_\text{out})\).