Skip to content

Simplify MLPool2dOptions by removing the outputSizes option #374

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

Open
huningxin opened this issue Apr 4, 2023 · 0 comments
Open

Simplify MLPool2dOptions by removing the outputSizes option #374

huningxin opened this issue Apr 4, 2023 · 0 comments

Comments

@huningxin
Copy link
Contributor

This is proposed by @wacky6 (Thanks Jiewei!) in Chromium CL review.

MLPool2dOptions has roundingType and outputSizes that both can control how an implementation calculates the shape of the output tensor. When the output sizes are explicitly specified, the options.roundingType is ignored. If not specified, the output sizes are automatically computed.

However, this design makes the implementation more complex. Specially, even if outputSizes is present, the implementation still needs to calculate the output tensor sizes for both "ceil" and "floor" rounding types for validating the user-supplied outputSizes, like Chromium's implementation. Removing the support of outputSizes option would help simplify the implementation.

Because the current frameworks widely support rounding type for pooling operators, such as PyTorch, ONNX and TensorFlow (only supports ceil mode), they can map to WebNN's MLPool2dOptions.roundingType directly without using the outputSizes option.

For native ML APIs that require the output sizes, like DirectML DML_AVERAGE_POOLING_OPERATOR_DESC and XNNPACK xnn_define_global_average_pooling_2d, WebNN implementation can set the calculated output sizes to them. For native ML APIs that accept rounding type, such as MPSGraph MPSGraphPooling2DOpDescriptor, WebNN implementation can map MLPool2dOptions.roundingType to native type.

/cc @wchao1115 @fdwr @pyu10055

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants