-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[webgpu] Add CeilDiv into webgpu utils
#26723
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
base: main
Are you sure you want to change the base?
Conversation
| static_cast<uint32_t>(((new_output_shape[0] + TILE_SIZE - 1) / TILE_SIZE))); | ||
| } else { | ||
| program.SetWorkgroupSize(WORKGROUP_SIZE); | ||
| program.SetWorkgroupSize(64u); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: why not use WORKGROUP_SIZE?
In line 134, please help correct it to uint32_t output_size = onnxruntime::narrow<uint32_t>(input_shape.Size());
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reasons:
- Specify workgroup_size=64 explicitly improve readability.
WORKGROUP_SIZEis defined asSafeInt<uint32_t>, it's not easy to cast back intouint32_twhich is required byCeilDiv.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems that it's not necessary to use SafeInt<uint32_t> for WORKGROUP_SIZE. WORKGROUP_SIZE is just a default value. If you are using 64 as the workgroup size, you can skip to call program.SetWorkgroupSize(64u); unless you are using a different value. Currently, a lot of ops are using the default WORKGROUP_SIZE. If you search, there should be many 'SetDispatchGroupSize((XXX + WORKGROUP_SIZE - 1) / WORKGROUP_SIZE). @fs-eire Do you think it's better to change the type of WORKGROUP_SIZE to uint32_t from SafeInt<uint32_t>? Or in all places, we explicitly specify the workgroup size.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally prefer to explicitly specify the workgroup_size. This practice improves code readability and saves time for developers read the source first time, as it eliminates the need to navigate to another file to figure out the default WORKGROUP_SIZE;
I have no objection if someone wishes to retain the implicit style.
|
/azp run Linux QNN CI Pipeline,Win_TRT_Minimal_CUDA_Test_CI,Windows ARM64 QNN CI Pipeline,Windows GPU Doc Gen CI Pipeline |
|
Azure Pipelines successfully started running 4 pipeline(s). |
| namespace onnxruntime { | ||
| namespace webgpu { | ||
| template <typename T> | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove empty line here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for identifying it.
Description
The
CeilDivfunction, which is heavily used by operations to determine dispatch sizes, was duplicated in multiple files. This PR moves the implementation into the common WebGPU utils to ensure a single source and reduce code duplication.Motivation and Context
See above.