fastmachinelearning / hls4ml

Machine learning on FPGAs using HLS
https://fastmachinelearning.org/hls4ml
Apache License 2.0
1.17k stars 388 forks source link

Add QDepthwiseConv2D, DepthwiseConv2D, DepthwiseConv1D support #834

Closed jmitrevs closed 10 months ago

jmitrevs commented 11 months ago

Description

There was a request to add support for QDepthwiseConv2D for QKeras. Previously we had Keras support for DepthwiseConv1D and DepthwiseConv2D but only as part of separable convolutions. This PR adds support for standalone DepthwiseConv1D and DepthwiseConv2D, and also QDepthwiseConv2D. Currently only depth_multiplier=1 is supported.

Note that QKeras doesn't support QDepthwiseConv1D.

Adding this found an issue in that arguments to activations passed as parameters to, e.g. QDense, such as activation='quantized_relu(3, 0)', were ignored. This had the same effect as activation='quantized_relu()'.

Type of change

Tests

Tests added to both test_keras_api.py and test_qkeras.py

Checklist

jmitrevs commented 11 months ago

I should also mention that this is only for 'io_stream` and only for Vivado and Vitis. There is not Quartus support.

jmitrevs commented 11 months ago

I think we should also support depth_multiplier!=1. Or is that not used often?

jmitrevs commented 10 months ago

@bo3z, are there any other things needed for this PR?

bo3z commented 10 months ago

@bo3z, are there any other things needed for this PR?

Looks good to me. Maybe worth opening an issue to keep track of the TODOs from this PR (resource strategy and multiplier != 1).