TECHNOLOGY

ONNX Runtime CPU OneHot: convert a fractional index before negative-index adjustment

In this article
THE QUICK TAKE

The 1.32 CPU OneHot repair applies index conversion before class logic; fractional, negative and nonfinite inputs need separate regression coverage.

ONNX Runtime 1.32.0 includes a CPU OneHot correction for fractional floating-point indices. The linked PR specifies conversion of finite representable inputs to int64 before negative-index adjustment and class comparison. The order matters: comparing a raw fractional value directly with an integer class can silently create an all-off row.

Input dtype does not remove conversion semantics

A floating input can still represent an index whose operator semantics require integer conversion. The PR repairs where that conversion occurs in the CPU path. A proposed reference should follow the specified conversion and range rules explicitly rather than rounding with a host-language convenience function. Testing only integer-valued floats cannot distinguish the corrected route from the old direct comparison, because both can agree on those special inputs.

Negative adjustment follows conversion

Negative indexing introduces another stage whose order must be preserved. Construct positive and negative fractional cases near zero and near the class-range boundary, checking the exact selected position or expected all-off result. Use a nondefault on/off pair so the chosen class is visually and numerically distinguishable. Do not infer correctness from output shape: an all-off tensor has the same shape as a correctly selected tensor.

Nonfinite and unrepresentable cases are distinct

The PR treats values that cannot safely become int64 as out of range. A local suite should therefore include NaN, infinities and finite values outside the representable range, alongside ordinary valid indices. These cases test conversion admission rather than class selection itself. A test harness should not pre-cast every input to integers, because doing so bypasses the floating-point branch whose behaviour the release changes.

Keep verification claims separate from release inclusion

The release lists the correction; the PR records its own reproduction and validation limitations. Those should not be rewritten as tests performed for this article. A local check should run the actual installed 1.32 build with the target opset and provider, then compare against an independent reference. The repair concerns conversion order and invalid-input handling, not a new guarantee that arbitrary preprocessing produces meaningful categorical labels.

Sources

Earn rental income from GPUs

Have idle GPUs or looking to fund AI infrastructure? Retrivium finds a rental platform, sets up the server and helps you assess income and costs with a pilot.

Explore GPU hosting
← All articles