Skip to content

Add signed BitShift support for opset 28 - #32361

Merged
mirounga merged 2 commits into
justinchuby-onnx-1-23-opset-28-basefrom
justinchuby-bitshift-28-signed-support
Sep 21, 2026
Merged

mirounga merged 2 commits into
justinchuby-onnx-1-23-opset-28-basefrom
justinchuby-bitshift-28-signed-support

Conversation

@justinchuby

Copy link
Copy Markdown
Contributor

Description

Adds ONNX BitShift opset 28 support for signed int8, int16, int32, and int64 tensors while preserving unsigned support.

  • Implements arithmetic right shift and raw-bit left shift without signed C++ shift undefined behavior.
  • Handles negative and out-of-range shift counts with the opset-28 0/-1 saturation semantics.
  • Splits CPU registrations at opset 28 and enables the previously missing uint16 kernel.
  • Caps DirectML's native BitShift kernel at opset 27 because DirectML masks out-of-range counts; opset 28 falls back to CPU for correct behavior.
  • Adds focused signed, unsigned, scalar, broadcast, wraparound, and out-of-range tests, and enables the ONNX uint16 backend tests.

Stacked on #32359.

Validation

onnxruntime_provider_test build is currently blocked by the base branch's unrelated tensorprotoutils.h numeric datatype map static assertion after the ONNX c78026fa update. The failure occurs across unrelated provider translation units before BitShift tests can link.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Generated kernel documentation is stale, backend exclusions remain, and the DirectML fallback boundary lacks targeted coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds CPU support for signed BitShift in opset 28 while preserving earlier unsigned behavior.

Changes:

  • Implements defined signed shift and saturation semantics.
  • Splits CPU registrations and enables uint16.
  • Caps DirectML support at opset 27 and expands tests.
File summaries
File Description
onnxruntime/core/providers/cpu/math/element_wise_ops.cc Implements safe shifts and registrations.
onnxruntime/core/providers/cpu/cpu_execution_provider.cc Registers opset-specific CPU kernels.
onnxruntime/core/providers/dml/DmlExecutionProvider/src/AbiCustomRegistry.cpp Caps DirectML BitShift support.
onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc Adds signed and unsigned tests.
onnxruntime/test/onnx/TestCase.cc Enables uint16 C++ backend tests.
Review details

Suppressed comments (1)

onnxruntime/core/providers/cpu/math/element_wise_ops.cc:1394

  • This else is unnecessary after the signed branch returns and violates the repository's AGENTS.md:108 no-else-after-return convention.
  } else {
    return result;
  • Files reviewed: 5/5 changed files
  • Comments generated: 5
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread onnxruntime/test/onnx/TestCase.cc
Comment thread onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc
Comment thread onnxruntime/core/providers/cpu/math/element_wise_ops.cc
Comment thread onnxruntime/core/providers/cpu/math/element_wise_ops.cc Outdated
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@mirounga
mirounga merged commit 81b968d into justinchuby-onnx-1-23-opset-28-base Sep 21, 2026
5 of 6 checks passed
@mirounga
mirounga deleted the justinchuby-bitshift-28-signed-support branch September 21, 2026 14:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants