SSD recipes
num_classes includes background. SSD300 accepts a selected prefix of 1–81
classes; the other recipes require their full emitted class count. A prefix
restricts eligible foreground classes to [1, num_classes) before candidate
selection/NMS. The confidence tensor still contains all 81 encoded classes, and
softmax still normalizes across all 81 logits, including excluded classes.
num_classes=1 therefore emits no detections. No tensor channels are truncated.
Each loc input has C=4A and each confidence input C=NA, where N is the encoded
class count shown below.
SsdRecipe | Model | Ordered square feature sizes | Anchors/cell | Classes | Activation |
|---|---|---|---|---|---|
Ssd300 | 300×300 | 38,19,10,5,3,1 | 4,6,6,6,4,4 | 81 | Softmax |
MobileNet300 | 300×300 | 19,10,5,3,2,1 | 3,6,6,6,6,6 | 91 | Sigmoid |
MobileNet320 | 320×320 | 20,10,5,3,2,1 | 3,6,6,6,6,6 | 91 | Sigmoid |
TorchVisionLite320 | 320×320 | 20,10,5,3,2,1 | 6,6,6,6,6,6 | 91 | Softmax |
SSD300 uses coordinate-major loc and class-major confidence channels. MobileNet uses anchor-major ty/tx/th/tw; TorchVision Lite uses anchor-major dx/dy/dw/dh; both use anchor-major confidence. Each recipe fixes its priors, 0.1/0.2 coder scales and background exclusion. Selection uses the score/tie-ordered lazy top-K/NMS policy.
See the common BoxDecode contract for errors, memory, outputs and qualification.
See geometry and decoding for the coordinate equations, operation order and precision used by the SSD paths.
Packed logical channel tiles
MlaCBlocked inputs use logical C tile extents, not padded physical pitches.
Both INT8 and BF16 accept nonmultiple-of-16 tiles. Partition the logical channels
first, then independently pad each slice to 16 lanes. For example, logical C34
with tile C17 stores two C32 slices, not a C32 slice followed by C16. The prepared
input requirement includes both padded slices and all spatial tiles.
Packed coordinates and scores are read directly with the prepared layout;
existing bounded score-pixel gathers remain. Admission does not add a full-tensor
copy or conversion, or change score activation, priors, decoding or tie order.
See the exact-carrier and partial-tile regressions (A65/boxdecode/tests/ssd_cblock_test.inc).
Dense MobileNet score readers
Dense/padded INT8 inputs are read directly from the current pixel. The foreground argmax loads only complete vectors within the logical class span, then handles the suffix scalarly; it does not require a copied or overallocated pixel. Each score port keeps its own quantization parameters, and background class zero remains excluded.
For dense/padded BF16 inputs, the scanner first finds the exact raw foreground
maximum. It retains the existing inverse-logit precheck and float sigmoid
threshold check, then locates the first matching raw encoding only for an
admitted anchor. No approximate activation or second maximum pass is added.
Raw signed-zero/NaN ordering, first-equal-raw ties and logical anchor order are
unchanged. See ssd.h (A65/boxdecode/detail/ssd.h) and
guarded/reused-context tests (A65/boxdecode/tests/scan_optimized_test.inc).
Exact BF16 softmax work reduction
After rejecting nonfinite BF16 logits, the softmax path recognizes a value whose
raw encoding equals the selected maximum. Its subtraction is exactly zero, so
its exponential is exactly 1.0f; no library call is needed. The same rule
applies to a winning numerator equal to that maximum. Other exponentials retain
the float implementation, and every denominator addition stays in its original
scalar order. Signed zeros that do not share an encoding still take the ordinary
subtraction/exponential path and produce the same value.
For contiguous per-anchor BF16 class rows, the foreground argmax also supplies the initial full-row maximum. Only excluded prefix/suffix classes need an additional comparison to find the denominator's maximum. This applies to TorchVision Lite's first background class and DETR's last background class. Prefix ties retain the earlier class's raw representation; suffix ties retain the foreground representation, including mixed signed zeros. The winner, exponential inputs, scalar addition order and threshold comparisons stay the same. SSD300's class-major reduction is separate; MobileNet recipes use sigmoid, not this softmax path.
SSD300's class-major INT8 and BF16 reductions retain the background row once, reduce the foreground maximum and first winning class, then combine the two maxima for the denominator. BF16 finite checks still include every class. Only the final row uses a bounded tail copy; earlier vector loads stay within the logical pixel. Neither background exclusion nor softmax accumulation order changes.
The optimization applies to the shared BF16 softmax machinery used by SSD and
DETR. It does not alter INT8 pair-table semantics, background exclusion,
first-class tie selection or exact threshold comparisons. Tests include one,
two and seven tied foreground maxima at the exact threshold and both adjacent
representable thresholds. See
execution.h (A65/boxdecode/detail/execution.h) and
scan_optimized_test.inc (A65/boxdecode/tests/scan_optimized_test.inc).