Skip to content

ConvTranspose has the wrong bias shape #1299

@yuanyao-nv

Description

@yuanyao-nv

In some exported model with ConvTranspose I'm seeing the wrong shape for bias:
image
image
where B should have shape (128) instead of (256) according to the ONNX spec.

Looking at the onnxscript code, the problem seems to be that since
_aten_convolution_onnx() is used for both Conv and ConvTranspose, the logic for filling in bias should check the 0th dimension of weight if it's Conv and the 1st dimension of weight if it's ConvTranspose:

    if bias is None:
        weight_dim_0 = op.Shape(weight, start=0, end=1)
        bias_shape = op.Expand(weight_dim_0, op.Constant(value_ints=[1]))
        zero = op.CastLike(0.0, input)
        bias = op.Expand(zero, bias_shape)

I think the value of groups is also needed since the shape of weight is (M x C/group x kH x kW) for Conv and (C x M/group x kH x kW) for ConvTranspose?

Metadata

Metadata

Labels

bugSomething isn't workingcontribution welcomeWe welcome code contributions for thismodule: torchlibRelated to the torch/aten function lib in development

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions