Skip to content

[WebGPU EP] adjusts pow op to use sqrt when exponent is 0.5 #25026

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 11 commits into from
Jun 16, 2025

Conversation

prathikr
Copy link
Contributor

@prathikr prathikr commented Jun 11, 2025

Resolves the below error for florence2 model by using WebGPU built-in sqrt(x) function instead of pow(x, y) when the exponent is 0.5. The sqrt(x) built-in is both faster and more stable than using pow(x, 0.5).

Non-zero status code returned while running Reshape node. Name:'/Reshape_1' Status 
Message: /Users/runner/work/1/s/onnxruntime/core/providers/cpu/tensor/reshape_helper.h:47 
  onnxruntime::ReshapeHelper::ReshapeHelper(const TensorShape &, TensorShapeVector &, bool) input_shape_size == size was false. 
  The input tensor cannot be reshaped to the requested shape. Input shape:{1,576,32}, requested shape:{1,23,23,32}

@prathikr prathikr marked this pull request as ready for review June 11, 2025 15:23
@prathikr prathikr added the ep:WebGPU ort-web webgpu provider label Jun 11, 2025
@prathikr prathikr requested review from fs-eire and guschmue June 11, 2025 15:23
@prathikr prathikr requested a review from guschmue June 11, 2025 16:50
@prathikr prathikr requested a review from guschmue June 11, 2025 20:14
@fs-eire
Copy link
Contributor

fs-eire commented Jun 11, 2025

please add a new unittest for the fix

@prathikr prathikr requested a review from fs-eire June 12, 2025 18:26
@prathikr prathikr requested a review from fs-eire June 12, 2025 21:10
@prathikr prathikr requested a review from fs-eire June 12, 2025 22:25
@prathikr prathikr merged commit 53f3c6c into main Jun 16, 2025
89 checks passed
@prathikr prathikr deleted the prathikrao/pow-sqrt-optimization branch June 16, 2025 18:01
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.

3 participants