Issue 175765
Summary [mlir][tosa] Convolution infer shape calculation appears to be incorrect when `bias=1`
Labels good first issue
Assignees
Reporter lhutton1
    Reproducer:
```
func.func @conv2d(%input: tensor<2x8x9x3xf32>, %weights: tensor<?x3x6x3xf32>, %bias: tensor<1xf32>, %input_zp: tensor<1xf32>, %weight_zp: tensor<1xf32>) -> () { 
   %0 = tosa.conv2d %input, %weights, %bias, %input_zp, %weight_zp {acc_type = f32, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>, dilation = array<i64: 1, 1>} : (tensor<2x8x9x3xf32>, tensor<?x3x6x3xf32>, tensor<1xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<?x?x?x?xf32>
 return
} 

$ mlir-opt --tosa-infer-shapes test.mlir

func.func @conv2d(%arg0: tensor<2x8x9x3xf32>, %arg1: tensor<?x3x6x3xf32>, %arg2: tensor<1xf32>, %arg3: tensor<1xf32>, %arg4: tensor<1xf32>) {
    %0 = tosa.conv2d %arg0, %arg1, %arg2, %arg3, %arg4 {acc_type = f32, dilation = array<i64: 1, 1>, pad = array<i64: 0, 0, 0, 0>, stride = array<i64: 1, 1>} : (tensor<2x8x9x3xf32>, tensor<?x3x6x3xf32>, tensor<1xf32>, tensor<1xf32>, tensor<1xf32>) -> tensor<2x6x4x1xf32>
    return
  }
```
>From the above example, the output channels dimensions is calculated to be of size 1, but this should be "?" since a bias of 1 may be broadcast over the actual number of output channels. From the [specification](https://www.mlplatform.org/tosa/tosa_spec_1_0_1.html):
```
Bias data will be broadcast if BC == 1.
```

I observed this behaviour in `tosa.conv2d`, but the following operations should also be checked `tosa.conv3d`, `tosa.depthwise_conv2d` for a possible fix.


_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to