conv2d: infer groups from input and filter shapes when not specified
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 42/100
- Issue type
- Feature
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- javascript, machine-learning
- Domain
- machine-learning
Research direction
Start with the MLConv2dOptions dictionary in the WebNN IDL and the conv2d() algorithm steps in the spec source, where groups is currently defaulted to 1 and validated. Remove the default, then add a step that infers groups from inputChannels / filterInputChannels when it is absent, with the TypeError checks described in the issue. Done means omitted groups infers correctly, explicit groups keeps current validation, and convTranspose2d is unchanged.
Written by the indexing model from the issue text.
Description
Problem
MLConv2dOptions.groups defaults to 1, so grouped convolutions only validate if groups is passed explicitly. LiteRT/TFLite CONV_2D does not carry a groups attribute; the group count is implied by inputChannels / filterInputChannels. Converters/delegates that map TFLite ops 1:1 to WebNN therefore fail validation for grouped convolutions:
TypeError: Failed to execute 'conv2d' on 'MLGraphBuilder':
The groups must evenly divide the input channels to filter input channels.
Evidence that TFLite/LiteRT has no groups attribute
- TFLite Schema:
Conv2DOptions= padding, stride_w/h, fused_activation_function, dilation_w/h_factor, quantized_bias_type — no groups - LiteRT C API exposes no Conv2d groups getter
- LiteRT Conv kernel derives it at runtime:
groups = input_channel / filter_input_channel
Real-world example: LiteRT.js EfficientViT segmentation demo
- Model: https://storage.googleapis.com/tfweb/litertjs_demo_models/efficientvit/efficientvit_seg_l2_ade20k_r512x512.tflite
- Input channels 1536, filter input channels 32 → implied groups = 48
- Downstream report: https://github.com/google-ai-edge/LiteRT/issues/9548
- Repro: https://litert.webnn.io/efficientvit-seg?backend=webnn-gpu&inference=1 (Chrome 154,
Enables WebNN APIflag enabled)
Proposal
-
Remove the
= 1default fromMLConv2dOptions.groupsin the IDL, so that an omittedgroupscan be distinguished from an explicitgroups: 1. -
In the
conv2d()method steps, whenoptions.groupsis not present, set:groups = inputChannels / filterInputChannelswhere both are read according to
inputLayoutandfilterLayout.
Throw a TypeError if the division is not exact, or ifoutputChannels % groups != 0.
An explicitly provided groups (including groups: 1) keeps today's validation unchanged.
convTranspose2d is out of scope: its filter's input-channel dimension always equals inputChannels, so groups cannot be inferred from shapes.
Cross-framework survey
- TFLite
CONV_2D: groups implicit (derived from input/filter shapes) - ONNX
Conv: explicitgroupattribute (default 1) - PyTorch
Conv2d: explicitgroups(default 1) - WebNN
conv2dalready supportsgroupson every backend, so this is only a front-end defaulting/validation change, not a new backend capability.
Alternatives considered
Fix in each delegate/converter (compute groups before calling conv2d). This works, but every implicit-group framework integration has to rediscover the rule, and the failure mode is a confusing validation error.
Backward compatibility
The default changes from "1" to "inferred". Graphs that are valid today stay valid: with groups omitted they already require inputChannels == filterInputChannels, so the inferred value is also 1.
@huningxin @fdwr PTAL
- Dominant language
- Bikeshed
- Stars
- 566
- Forks
- 72
- Avg merge
- 6d 5h
- Merged PRs (30d)
- 1
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from webmachinelearning/webnn
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
webmachinelearning/webnn#967 ·
-
Difficulty 5/5 Over a week Newbie friendliness 25/100
webmachinelearning/webnn#966 · 1 comment ·
-
Difficulty 5/5 Over a week Newbie friendliness 35/100
webmachinelearning/webnn#965 · 1 comment ·
-
Difficulty 3/5 1-2 days Newbie friendliness 68/100
webmachinelearning/webnn#964 · 1 comment · 1 reaction ·
-
Difficulty 5/5 Over a week Newbie friendliness 30/100
webmachinelearning/webnn#963 · 3 comments · 2 reactions ·
All issues in webmachinelearning/webnn
Similar issues
-
Validate non-divisible effective batch sizes in the Unsloth LoRA backendPossibly taken @debesh-biswas claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
PaddlePaddle/PaddleX#5231 ·
Maintainers usually reply within 1 day
-
01-palmyra-vision section 6 never sends an image through Converse, so the bedrock-runtime path has no vision examplePossibly taken @sample-per-model-bedrock-dev-agent claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
aws-samples/sample-per-model-bedrock#437 · 1 comment ·
Maintainers usually reply within 1 day
-
benchmark good first issue help wanted
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
alessioricco/Certo#18 ·
-
security severity:high
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Maintainers usually reply within 2 days