Skip to content

Fix Conv2D with `io_type = io_parallel` & `Strategy: Resource`

Javier Duarte requested to merge conv2d_para_resource_fix into master

Created by: thesps

Currently a Conv2D layer with io_type = io_parallel & Strategy: Resource gives wrong results. The loops of im2col_2d_cl needed reordering.

test_cnn_mnist.py probes the issue. On master branch the problematic combination is excluded, but if we run it we see:

Accuracy keras:      0.9838
Accuracy hls4ml:     0.112
Relative difference: 0.8861557227078675

>     assert acc_keras > 0.95 and rel_diff < 0.01
E     assert (0.9838 > 0.95 and 0.8861557227078675 < 0.01)

test_cnn_mnist.py:72: AssertionError

Now it can be included, passing with:

Accuracy keras:      0.9838
Accuracy hls4ml:     0.9834
Relative difference: 0.0004065867046147143

I've also reduced the number of MNIST images used in the test from 10000 to 5000, since that test was already the slowest and this PR adds another iteration of it.

Solves issue #375 (closed) , and also seen in issue #437 (closed).

For completeness: this doesn't touch io_stream implementations, they're all fine. I haven't touched im2col_2d_cf, but is that even accessible?

Merge request reports

Loading