Work record: , 4 minute read

The 71 transposes that were one operation

An accelerator compiler rejected a tangle of tensor operations. Replacing the underlying permutation preserved the floating-point graph—but the throughput headline was not the cost of a real call.

Terminal readout of the Hailo-8 inference path: inferences, frame ages, zero wasted decodes
Terminal readout of the Hailo-8 inference path: inferences, frame ages, zero wasted decodesOpen image to inspect at full size.

XFeat is a lightweight feature extractor and matcher. Hailo-8 accelerates compatible neural graphs, but compatibility is not automatic: the compiler rejected the graph produced by the original export.

the Hailo dataflow compiler on stock XFeat, summarised
UnsupportedShuffleLayerError
  Transpose   × 71   (5-D)
  Slice       × 72   (5-D)
  Unsqueeze   × 70   (5-D)

The tempting move is to fight 213 operations. The useful move was noticing they aren’t 213 problems, or even 71. They’re one: a helper called _unfold2d(x, ws=8), written with Tensor.unfold, which PyTorch traces as a pile of five-dimensional slicing. That operation has a name, space-to-depth: fold each 8 × 8 patch of pixels into 64 channels. PyTorch already has it as pixel_unshuffle, and the chip supports that natively. One substitution, and the graph parses.

Space-to-depth: an 8 by 8 patch of a single-channel image becomes one pixel with 64 channels. The image shrinks 8 times in each direction and gains 64 times the channels; no values change.8 × 8 patch, 1 channelpixel_unshuffle(8)1 pixel, 64 channels. Same numbers, new address.
What 213 unsupported operations were actually doing: moving numbers, not changing them. That’s why an exact substitute could exist.

The proof, not the claim

Compilation alone cannot establish equivalence. A graph that quietly changes the feature layout can degrade matching and make quantisation look responsible. The export check compares the replacement operation and the complete floating-point network with the stock graph at the supported resolutions. The recorded checks used torch.equal for the permutation and reported zero maximum difference across the network’s three output heads on the tested inputs.

the export check, summarised: both resolutions, all three heads
unfold2d vs pixel_unshuffle  torch.equal: True
full network vs stock        max |Δ| = 0.000e+00
→ ONNX export allowed; compile and INT8 evaluation follow

The structural reason an exact replacement is possible is that space-to-depth rearranges values rather than estimating new ones. Channel order, block order and supported image dimensions still have to agree. A finite equality check guards the actual export; it is not a claim about arbitrary unsupported input shapes. Nor does floating-point equality prove that the later INT8 model preserves matching quality.

A HEF that compiles is not a result.

Throughput is not the cost of a call

The archived 320 × 240 measurements contain two different comparisons:

MeasurementRecorded valueScope
Hailo-8 sustained backbone throughput701.22 frames/sBatched chip benchmark, not complete matching
Pi CPU backbone benchmark30.2 frames/sThe earlier CPU comparison
Hailo single detect() call13.4 msHost call through InferVStreams
CPU call in the same single-shot script20.0 msThe corresponding application-facing comparison

The first pair produces the roughly 23-fold throughput headline. The second gives about a 1.5-fold improvement per call in that historical harness. The distinction is consequential: a control loop cannot spend batched throughput as though each newly captured image returns in its reciprocal time.

The single-shot path paid host-API and network-activation overhead. The backbone was only one stage, too: keypoint decoding, non-maximum suppression and feature matching remained on the CPU. These are archived measurements from this revision, not the present shared-camera graph’s latency or a claim of 701 complete matches per second.

Spend the saved work where it matters

The change made an otherwise rejected graph compilable without intentionally approximating the floating-point operation. The next question was whether its output remained useful after quantisation and through the actual postprocessor. That requires a separate task-level comparison; the canary investigation and the fine-tuning retraction show why an attractive backbone number cannot answer it.

The matcher also has a different scaling law. Comparing K query descriptors with K reference descriptors builds a similarity matrix whose pair count grows as K². Doubling keypoints can quadruple that part of the work without doubling the useful geometric evidence. That is why the choice between denser features and more reference views needs a cost-and-quality experiment, not the accelerator’s TOPS rating.

The archived configuration preferred four references at top_k = 1024 over one at 2048 under its measured budget. That is a result for its footage and settings, not a universal optimum. Profiling the bank then uncovered repeated feature extraction on identical pixels: the next investigation.