Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

conv2d: infer groups from input and filter shapes when not specified

Closed
#959 1 comment 1 reaction 0 assignees View on GitHub

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

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

Agenda+
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
Proposal
  1. Remove the = 1 default from MLConv2dOptions.groups in the IDL, so that an omitted groups can be distinguished from an explicit groups: 1.

  2. In the conv2d() method steps, when options.groups is not present, set:

    groups = inputChannels / filterInputChannels
    

    where both are read according to inputLayout and filterLayout.
    Throw a TypeError if the division is not exact, or if outputChannels % 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: explicit group attribute (default 1)
  • PyTorch Conv2d: explicit groups (default 1)
  • WebNN conv2d already supports groups on 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

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from webmachinelearning/webnn

All issues in webmachinelearning/webnn

Similar issues

More Machine Learning issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.