[WebGPU EP] Support int64 for Min and Max - #31709
Open
Wanming Lin (Honry) wants to merge 2 commits into
Open
Conversation
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Wanming Lin (Honry)
force-pushed
the
webgpu-int64-minmax
branch
2 times, most recently
from
August 7, 2026 08:21
9817d52 to
78abe6c
Compare
Registers the WebGPU Min and Max kernels with conditional int64 support, mirroring the existing Add/Sub/Equal int64 mechanism. The kernels were previously registered with WebGpuSupportedNumberTypes() (float/fp16/ int32/uint32 only), causing int64 tensors to fall back to CPU. Min/Max are arithmetic/comparison ops, so they reuse the existing low-32-bit i32 shader path (like Add/Sub). Values outside the int32 range produce incorrect results, which is acceptable for token-position workloads and consistent with the other arithmetic int64 kernels. int64 support is gated behind the enableInt64 provider option, so the generic Min_12_Int64/Max_12_Int64 tests do not exercise it. Added WebGPU int64 tests (int64 enabled, CPU-EP fallback disabled) mirroring the Add int64 path coverage, element-wise, size divisible by 4, scalar operand, broadcast, plus the variadic (>2 input) fold unique to Min/Max, with INT32_MIN/INT32_MAX exercising the supported range edges.
Contributor
Author
Contributor
|
Since int64 support is needed for an increasing number of binary ops, could you consider enabling int64 support across all binary ops behind the enableInt64 flag? It would also be great to reuse as much common code as possible so that the overall int64 support for binary ops can be implemented and maintained consistently. |
| return Status::OK(); | ||
| } | ||
|
|
||
| // A single opset version range for an op registration. end <= 0 means "since start" (open-ended). |
Contributor
There was a problem hiding this comment.
maybe std::optional<int> end would be clearer than having special handling for values <= 0?
Comment on lines
+489
to
+490
| int start; | ||
| int end; |
Contributor
There was a problem hiding this comment.
nit: the names begin/end feel more consistent. e.g., std::begin()/std::end()
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.
Description
Registers the WebGPU Min and Max kernels with conditional int64 support, mirroring the existing Add/Sub/Equal int64 mechanism. The kernels were previously registered with
WebGpuSupportedNumberTypes()(float/fp16/ int32/uint32 only), causing int64 tensors to fall back to CPU.Motivation and Context
Min/Max are arithmetic/comparison ops, so they reuse the existing low-32-bit i32 shader path (like Add/Sub). Values outside the int32 range produce incorrect results, which is acceptable for token-position workloads and consistent with the other arithmetic int64 kernels.
int64support is gated behind the enableInt64 provider option, so the genericMin_12_Int64/Max_12_Int64tests do not exercise it. Added WebGPU int64 tests (int64 enabled, CPU-EP fallback disabled) mirroring the Add int64 path coverage, element-wise, size divisible by 4, scalar operand, broadcast, plus the variadic (>2 input) fold unique to Min/Max, with INT32_MIN/INT32_MAX exercising the supported range edges.