Repository navigation
[WebGPU] Support signed 8-bit and 64-bit unary math - #33958
Merged
Sushanth Rajasankar (sushraja-msft) merged 9 commits intoNov 13, 2026
Merged
Sushanth Rajasankar (sushraja-msft) merged 9 commits into
Sushanth Rajasankar (sushraja-msft) merged 9 commits into
Conversation
Add Abs, Neg, Relu and Sign kernels without truncating 64-bit values. Cover runtime and initializer inputs, scalar and empty tensors, packed byte tails, signed limits and carries with CPU fallback and constant folding disabled. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
The NHWC layout transformer only accepts model opset 7 or newer. Use opset 7 to execute the existing 6-12 registrations instead of requesting an unsupported opset 6 graph. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Unpack signed bytes in UnaryElementwise and reuse its operation expressions. Keep full-width two-word arithmetic in Int64Unary and Int64UnaryProgram. Add GPU-only float32/int32 compatibility coverage alongside the existing integer tests. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Process padding lanes independently without an element-count uniform. Rename the plugin tests to reflect integer and floating-point unary coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename IntegerUnaryOp to Int64UnaryOp and document the packed word layout, two-complement carry, and per-operation selection. Shader arithmetic is unchanged. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Sushanth Rajasankar (sushraja-msft)
marked this pull request as ready for review
November 9, 2026 06:31
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The new int64 Abs, Neg, Sign, and Relu kernels are registered even when enable_int64 is false, bypassing the documented opt-in and requiring guarded registration with enabled and disabled configuration coverage.
1 open issue
What changed in this PR
Adds signed int8 and int64 support for Abs, Neg, Relu, and Sign in ONNX Runtime’s WebGPU execution provider, expanding integer operator coverage for WebNN conformance.
Changes:
- Adds packed int8 handling and full-width, two-word int64 unary arithmetic.
- Registers the new int64 kernels across supported operator versions.
- Adds GPU-only integer tests and float32/int32 compatibility checks, including scalar, empty, and initializer inputs.
| File | Description |
|---|---|
onnxruntime/test/providers/webgpu/plugin/unary_elementwise_ops_test.cc |
Adds integer unary and compatibility tests with CPU fallback disabled. |
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc |
Adds versioned int64 unary kernel registrations. |
onnxruntime/core/providers/webgpu/math/unary_elementwise_ops.cc |
Implements int8 unpacking and int64 unary shaders; extends supported types. |
Review effort: Balanced
Register all int64 unary opset ranges conditionally, following Clip. Cover disabled int64 rejection and unaffected int8 execution alongside enabled GPU arithmetic, and document the full-width opt-in behavior. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot stopped reviewing on behalf of
Sushanth Rajasankar (sushraja-msft) due to an error
November 9, 2026 07:39
Contributor
There was a problem hiding this comment.
Note
Copilot was unable to run its full agentic suite in this review.
Copilot review overview
3 open issues
The range described for i32 truncation is inaccurate/incomplete: truncation is lossy for values… · New This registration block is highly repetitive and error-prone to maintain (e.g., adding another… · New This new macro is introduced in this change but isn’t used anywhere in the shown diff. If it’s… · New
1 resolved since last review
Review effort: Lite
Generate each operation registrar alongside its kernel definitions so opset ranges have one source of truth. Remove the unused versioned typed helper and document both signed int32 truncation bounds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Use WGSL unpack4xI8 for signed byte lanes and share the output statement. Use overflow-safe CeilDiv for int64 dispatch while keeping the empty-tensor return. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Jiajia Qin (qjia7)
approved these changes
Nov 12, 2026
Sushanth Rajasankar (sushraja-msft)
merged commit Nov 13, 2026
fd249b5
into
main
101 of 103 checks passed
Sushanth Rajasankar (sushraja-msft)
deleted the
user/sushraja/webgpu-integer-unary
branch
November 13, 2026 06:06
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Adds signed int8 and int64 support for Abs, Neg, Relu, and Sign to improve WebGPU EP coverage on WebNN WPT tests.
The measured WebNN WPT pass rate increased from 96.6% (1,691/1,751) to 97.1% (1,701/1,751) in combined validation. Eight newly passing integer unary cases correspond to this change; the other two gains are not attributed to this PR. The selection excludes float16 input/output cases.
Int64 unary kernels respect the
enableInt64opt-in; int8 support is unaffected.Validation: all 12 native unary tests pass with no skips, covering enabled/disabled int64 configurations with CPU fallback disabled. WPT measurements predate the subsequent kernel refactor; WPT was not rerun afterward.