assignment.assignment_cost
def assignment_cost(cost: torch.Tensor, matches: torch.Tensor, reduction: str = 'sum') -> torch.TensorCompute the total cost of a LAP assignment.
Parameters
| Name | Type | Description |
|---|---|---|
| cost | torch.Tensor | Cost matrix (N, M) or (B, N, M). float32 or float64. |
| matches | torch.Tensor | Row→col assignment (N,) or (B, N). int64. Unmatched rows have ``-1``. |
| reduction = 'sum' | str | How to aggregate per-row costs: ``"sum"`` (default) sums all matched rows; ``"mean"`` divides by the number of matched rows; ``"none"`` returns per-row costs with unmatched rows set to 0. |
Returns
total — Scalar for 2-D input or (B,) for 3-D input, unless ``reduction="none"``, in which case the shape is (N,) or (B, N).
Source: torchmatch/assignment/_cost.py:8