Xilinx / finn

Dataflow compiler for QNN inference on FPGAs
https://xilinx.github.io/finn
BSD 3-Clause "New" or "Revised" License
723 stars 230 forks source link

Expand support for grouped convolutions #918

Open nickfraser opened 11 months ago

nickfraser commented 11 months ago

Details

As discussed in #883, grouped convolutions (i.e., groups>1) are only supported when in_channels == out_channels == groups. LowerConvsToMatMul fails with a reshape error.

New behavior

Ideally, it would be great to expand support for arbitrary grouped convolutions. In particular, it could be low hanging fruit to expand current support to allow in_channels == groups and out_channels = n*groups (where n is an integer >1) as this would simply result in individual input channels being broadcasted to multiple output channels.

Motivation

Current support handles the common case of standard depthwise-separable convolutions well, but grouped convolutions are becoming more popular as a general optimization strategy to reduce the amount of weights / ops in a given layer.

Parts of FINN affected

Certainly the LowerConvsToMatMul transform in the FINN compiler is affected. It's likely that some changed would need to be made to FINN-HLSLIB as well.