Skip to content

Conversation

@fs-eire
Copy link
Contributor

@fs-eire fs-eire commented Apr 7, 2025

Description

This PR is one of a series of changes for optimization of Dawn API usage. See #24281

Optimize the code for workgroup dispatch in the WebGpuContext class.

The updated code prefers using the C-API instead of the C++ API for WebGPU. This is because the C++ API uses class wgpu::Buffer, which causes significant amount of calls to wgpuBufferAddRef and wgpuBufferRelease to ensure the lifecycle of the buffer is managed correctly. For this specific use case in ONNX Runtime (launch a compute shader program), using the C-API is more efficient.

@fs-eire fs-eire added the ep:WebGPU ort-web webgpu provider label Apr 7, 2025
@fs-eire fs-eire merged commit cda0d14 into main Apr 8, 2025
85 of 89 checks passed
@fs-eire fs-eire deleted the fs-eire/wgpu-buffer-3 branch April 8, 2025 23:30
zhaoxul-qti pushed a commit to CodeLinaro/onnxruntime that referenced this pull request Apr 17, 2025
### Description

This PR is one of a series of changes for optimization of Dawn API
usage. See microsoft#24281

Optimize the code for workgroup dispatch in the `WebGpuContext` class.

The updated code prefers using the C-API instead of the C++ API for
WebGPU. This is because the C++ API uses class `wgpu::Buffer`, which
causes significant amount of calls to `wgpuBufferAddRef` and
`wgpuBufferRelease` to ensure the lifecycle of the buffer is managed
correctly. For this specific use case in ONNX Runtime (launch a compute
shader program), using the C-API is more efficient.
ashrit-ms pushed a commit that referenced this pull request Apr 24, 2025
### Description

This PR is one of a series of changes for optimization of Dawn API
usage. See #24281

Optimize the code for workgroup dispatch in the `WebGpuContext` class.

The updated code prefers using the C-API instead of the C++ API for
WebGPU. This is because the C++ API uses class `wgpu::Buffer`, which
causes significant amount of calls to `wgpuBufferAddRef` and
`wgpuBufferRelease` to ensure the lifecycle of the buffer is managed
correctly. For this specific use case in ONNX Runtime (launch a compute
shader program), using the C-API is more efficient.
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