Skip to content

WebGPU: Support int64 for Add operator - #29844

Merged
hariharans29 merged 4 commits into
microsoft:mainfrom
huningxin:copilot/add-int64-support-to-add-operator
Jul 27, 2026
Merged

WebGPU: Support int64 for Add operator#29844
hariharans29 merged 4 commits into
microsoft:mainfrom
huningxin:copilot/add-int64-support-to-add-operator

Conversation

@huningxin

Copy link
Copy Markdown
Contributor

Description

Extends the WebGPU EP Add operator to accept tensor(int64) inputs by converting its registration from a static macro to the same conditional factory-function pattern already used by Sub and Equal (#29392)

Motivation and Context

Int64 Add nodes (e.g. token-position arithmetic in LLMs, mobileclip_s0 text model) fail kernel lookup in the WebGPU EP.

The shader already handles int64 generically for all binary ops; only the kernel registration was missing the int64 type constraint for Add.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@huningxin

Copy link
Copy Markdown
Contributor Author

@hariharans29, PTAL, thanks!

/cc @adrastogi

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.

Pull request overview

Extends the WebGPU EP Add kernel registration to include tensor(int64) when enable_int64 is set, matching the conditional factory-function registration pattern already used for other WebGPU ops (e.g., Sub, Equal). This resolves WebGPU kernel-lookup failures for INT64 Add nodes (notably in graph-capture flows where INT64 is enabled).

Changes:

  • Convert Add WebGPU kernel registration from static macro entries to conditional CreateAdd*KernelInfo(...) factory functions, registered via RegisterKernels(enable_int64).
  • Add WebGPU unit tests covering INT64 Add for elementwise, broadcast, scalar LHS/RHS, and size-divisible-by-4 cases.
  • Expose CreateAdd*KernelInfo declarations in binary_elementwise_ops.h for use by the WebGPU EP registry.
Show a summary per file
File Description
onnxruntime/test/providers/cpu/math/element_wise_ops_test.cc Adds USE_WEBGPU-guarded tests validating INT64 Add execution on WebGPU with kEnableInt64=1.
onnxruntime/core/providers/webgpu/webgpu_execution_provider.cc Removes static Add registration and registers Add via RegisterKernels() using conditional INT64 type constraints.
onnxruntime/core/providers/webgpu/math/binary_elementwise_ops.h Declares CreateAddVersionedKernelInfo / CreateAddKernelInfo templates for EP registration.
onnxruntime/core/providers/webgpu/math/binary_elementwise_ops.cc Implements CreateAdd*KernelInfo and explicitly instantiates the supported versions (7–12, 13, 14+).

Review details

  • Files reviewed: 4/4 changed files
  • Comments generated: 0
  • Review effort level: Low

@huningxin

Copy link
Copy Markdown
Contributor Author

Fixed the merge conflicts, @hariharans29, please take another look, thanks!

@hariharans29
hariharans29 enabled auto-merge (squash) July 27, 2026 22:09
@hariharans29
hariharans29 merged commit c1c8bfc into microsoft:main Jul 27, 2026
86 checks passed
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