You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Mandate output_channels % groups == 0 validation for conv2d #925
Background
Currently, the WebNN specification for conv2d ensures that the input channels are evenly divisible by the groups attribute (e.g., verifying that the filter's input channel dimension matches input_channels / groups). However, it lacks a symmetric validation step explicitly ensuring that the output channels are also perfectly divisible by groups.
The Issue
Without this explicit validation mandated by the specification, backend engines may encounter mathematically invalid graphs that lead to undefined behavior. If a developer provides an output_channels value that is not a multiple of groups, it frequently triggers integer truncation bugs in the backend's channel-to-group assignment logic.
Proposed Specification Change
To protect all underlying machine learning frameworks from this class of malformed tensor, we propose adding an explicit validation step to the WebNN spec for conv2d.
The specification must mandate that the total number of output channels is a multiple of the groups attribute.
Motivation
Enforcing this strictly at the WebNN API level guarantees that all backends—whether TFLite, DirectML, or CoreML—are shielded from processing mathematically impossible grouped convolutions. This eliminates an entire class of potential buffer overflows before the graph is ever compiled.
Future Consideration
While convTranspose2d does not currently support groups > 1, this exact same validation rule will be critical to implement for transposed convolutions if group support is added in the future, as an integer division flaw there would result in an Out-Of-Bounds Write.
Activity
anssiko commentedon Apr 23, 2026
Validate output channels are a multiple of groups in conv2d (webmachi…
Validate output channels are a multiple of groups in conv2d (#925) (#932
Validate output channels are a multiple of groups in conv2d (#925) (#932
anssiko commentedon Sep 7, 2026
Fixed by #932
(Belated thank you to @lynne0326 for both identifying and subsequently fixing the issue, improving the security of this API!)