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

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

Author: Retrivium team
Updated: 2026-11-15
Canonical URL: https://retrivium.ai/journal/week46-engine-ort-onehot-fractional-index-conversion/
Language: en

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

- [ONNX Runtime v1.32.0 release](https://github.com/microsoft/onnxruntime/releases/tag/v1.32.0)
- [ONNX Runtime pull request #33273](https://github.com/microsoft/onnxruntime/pull/33273)

## Related reading

- [ONNX compatibility: distinguish IR version, domain opsets and model revision](/journal/fg2-onnx-ir-version-opset-domain-separation/)
- [ONNX optional inputs: preserve positions when a middle argument is absent](/journal/fg2-onnx-optional-input-empty-placeholder-position/)
