-
Notifications
You must be signed in to change notification settings - Fork 59
Description
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