onnxruntime
9ddcd77f - Fix CPU OneHot handling of fractional floating-point indices (#33273)

Commit
2 days ago
Fix CPU OneHot handling of fractional floating-point indices (#33273) ## Summary Fixes #33272 Corrects the CPU `OneHot` operator's handling of fractional floating-point indices to comply with the ONNX specification. Previously, valid fractional indices could silently produce all-off rows instead of selecting their corresponding class after conversion to `int64`. ## Changes - Convert finite, representable floating-point indices to `int64` before negative-index adjustment and class comparison. - Safely treat nonfinite and unrepresentable floating-point indices as out of range. - Preserve existing integer-index handling. - Add CPU regression tests for positive and negative fractional indices, out-of-range values, nonfinite values, and integer-valued floats. - Cover both opsets 9 and 11 for fractional-index behavior. ## Testing **Verified:** - Independently reproduced the original bug with ONNX Runtime 1.31.0 on Kaggle/Linux using `CPUExecutionProvider`. - Also reproduced the original behavior with ONNX Runtime 1.23.2 locally. - `clang-format` passed. - Full `lintrunner` passed. - `git diff --check` passed. **Not yet verified:** - The patched C++ implementation has not been successfully built or executed. - The new C++ regression tests have not been run. - The Kaggle source build is not yet confirmed successful. Local compilation was blocked by missing build dependencies and toolchain components. CI validation is needed to establish whether the patch compiles and passes provider tests. ## AI assistance OpenAI Codex assisted with investigation, implementation, and regression-test development. I independently reproduced the reported behavior, reviewed the source changes, and verified the available formatting and lint results. ## Related issue Fixes #33272
Author
Parents
Loading