fastmachinelearning / hls4ml

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

Remove double transpose for Conv2DBatchnorm #965

Open jmitrevs opened 4 months ago

jmitrevs commented 4 months ago

Description

In the layers.py Conv2DBatchnorm makes a transpose if it is the resource strategy, but only for Vivado and VivadoAccelerator backends. Note that Conv2DBatchnorm inherits from Conv2D, and Conv2D makes the same transpose in:

https://github.com/fastmachinelearning/hls4ml/blob/main/hls4ml/backends/vivado/passes/resource_strategy.py#L29-L32

I think therefore the transpose is doubly-applied. I am therefore removing the backend-specific transpose in the layers.py, which regardless does not belong there.

Type of change

Tests

I assume there's a Conv2DBatchnorm test that will catch this change, but maybe not.

Test Configuration:

Checklist

jmitrevs commented 4 months ago

This was motivated by issue #957