Skip to content

[WebGPU] Support signed 8-bit and 64-bit unary math - #33958

Merged
Sushanth Rajasankar (sushraja-msft) merged 9 commits into
mainfrom
user/sushraja/webgpu-integer-unary
Nov 13, 2026
Merged

Sushanth Rajasankar (sushraja-msft) merged 9 commits into
mainfrom
user/sushraja/webgpu-integer-unary

Conversation

@sushraja-msft

@sushraja-msft Sushanth Rajasankar (sushraja-msft) commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

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 enableInt64 opt-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.

Sushanth Rajasankar and others added 6 commits November 6, 2026 14:59
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>

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

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 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.

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>

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.

🟢 Approval recommended

No active review issues are identified for the expanded WebGPU integer unary operator support.

No open issues 🎉

3 resolved since last review

Review effort: Balanced

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants