Skip to content

[WebGPU EP] Support int64 for Tile and Concat - #31049

Merged
Hariharan Seshadri (hariharans29) merged 21 commits into
microsoft:mainfrom
miaobin:webgpu-concat-int64
Aug 4, 2026
Merged

[WebGPU EP] Support int64 for Tile and Concat#31049
Hariharan Seshadri (hariharans29) merged 21 commits into
microsoft:mainfrom
miaobin:webgpu-concat-int64

Conversation

@miaobin

@miaobin Bin Miao (miaobin) commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Description

  • Adds int64 data type support to the Tile operator in the WebGPU execution provider. The op is used by yolo26n-pose and other models that tile int64 tensors.
  • Adds int64 data type support to the Concat operator in the WebGPU execution provider. The op is used by whisper-base-decoder iobinding model that concat int64 tensors.

Motivation and Context

The WebGPU Tile and Concat kernels were registered with WebGpuSupportedNumberTypes() (float/fp16/int32/uint32 only), causing int64 tensors to fall back to CPU. Beyond the missing type constraint, the WGSL getter for Int64 variables returns only the low 32 bits (i32(buf[offset].x)), and the default setter sign-extends from that i32 — silently corrupting any value with non-zero high bits. Since Tile and Concat are pure data-movement with no arithmetic on element values, int64 is safe to support by treating each element as an opaque vec2 copy.

Copilot AI and others added 17 commits July 24, 2026 23:48
- Replace ONNX_OPERATOR macro registrations with CreateTileVersionedKernelInfo/
  CreateTileKernelInfo factory functions gated by enable_int64 (mirrors Reshape,
  Expand, Sub, etc.)
- Update TileProgram to carry an is_int64_ flag; when true, GenerateShaderCode
  copies the raw vec2<u32> storage via IndicesToOffset + SetByOffset(use_storage_type)
  to preserve all 64 bits instead of sign-extending from i32
- Register Tile kernels via RegisterKernels() with the enable_int64 flag
- Include tile.h in webgpu_execution_provider.cc; remove old BuildKernelCreateInfo
  entries for Tile from the static table
- Add TileInt64TypeWebGpu test using values with non-zero high 32 bits
For segmented get_*_by_offset, Boolx4 now unpacks the u32 storage word
into vec4<bool> using the same bit-mask pattern as GetByOffsetImpl,
instead of returning the raw u32 as the declared vec4<bool> return type.

For segmented set_*_by_offset, Boolx4 now packs vec4<bool> into u32
using dot(vec4<u32>(0x1,...), vec4<u32>(value)), matching SetByOffsetImpl,
instead of assigning a vec4<bool> directly to a u32 storage slot.
…64-support-tile-op

WebGPU: fix segmented int64/uint64 accessor typing and add segmented storage setter path
Mirror the Int64 case: when use_storage_type=true, write the value
directly (caller provides vec2<u32>); when false (default), zero-extend
u32 to vec2<u32> as before. Fixes latent WGSL type error if a caller
ever does a storage-typed round-trip on a Uint64 variable.
…64-support-tile-op-again

WebGPU: Fix Uint64 non-segmented SetByOffsetImpl to honor use_storage_type
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…64-support-tile-op-another-one

WebGPU Tile int64: prevent CPU EP fallback in test, fix GetByOffset doc comment
…64-support-tile-op-yet-again

WebGPU EP: Add int64 support for Tile operator
Adds int64 to the WebGPU `Concat` type constraint so int64 Concat nodes stop
falling back to the CPU EP. Concat registration is migrated from static macro
registration to the `enable_int64` factory-registration pattern already used by
Reshape/Expand/Add, and int64 WebGPU test coverage is added.
@azure-pipelines

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

@miaobin

Copy link
Copy Markdown
Contributor Author

@hariharans29

Copy link
Copy Markdown
Member

Thanks - will review this once the Tile changes are merged in here.

Bin Miao (miaobin) and others added 2 commits July 30, 2026 15:16
Co-authored-by: huningxin <ningxin.hu@intel.com>
Updates the WebGPU Concat kernel to copy int64/uint64 elements using the raw
vec2<u32> storage word instead of the truncating i32 value type, preserving the
full 64-bit value. The Concat shader gains an is_int64 branch that converts the
output indices to an offset and uses the storage-type GetByOffset/SetByOffset
accessors (use_storage_type=true).

The int64 test now concatenates values outside the int32 range (2^32, 2^33+1, a
large negative, INT64_MAX) to prove the value is preserved rather than truncated.
@miaobin Bin Miao (miaobin) changed the title [WebGPU EP] Support int64 for Concat [WebGPU EP] Support int64 for Tile and Concat Jul 30, 2026
@miaobin

Copy link
Copy Markdown
Contributor Author

Thanks - will review this once the Tile changes are merged in here.

Tile changes have been merged here and the latest commit makes int64 Concat lossless via raw vec2 copy (similar to Tile). PTAL, thanks.

auto-merge was automatically disabled July 31, 2026 05:17

Head branch was pushed to by a user without write access

@miaobin

Copy link
Copy Markdown
Contributor Author

Fixed clang-format trailing comment alignment. Hariharan Seshadri (@hariharans29) Please take another look, thanks a lot!

Comment thread onnxruntime/core/providers/webgpu/shader_variable.cc Outdated
Comment thread onnxruntime/core/providers/webgpu/tensor/concat.cc
The segmented get/set-by-offset accessor codegen built sub-expressions with
MakeStringWithClassicLocale(), which uses the heavier std::ostringstream,
inside functions that otherwise use the lightweight FastOStringStream
(via the SS/SS_APPEND macros).
@miaobin

Bin Miao (miaobin) commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Updated the PR to address the comments. Hariharan Seshadri (@hariharans29) Edward Chen (@edgchen1) Please take another look, thanks a lot!

@hariharans29
Hariharan Seshadri (hariharans29) merged commit f6d5554 into microsoft:main Aug 4, 2026
86 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ep:WebGPU ort-web webgpu provider

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants