Skip to content

Valid padding in pooling layers can cause OOB errors

Javier Duarte requested to merge github/fork/vloncar/pooling_valid_fix into master

Created by: vloncar

E.g., in a MaxPooling2D layer with pool size 2x2 and stride 2x2 on a 5x5 input the last row/column should be dropped. Otherwise, we can have out-of-bounds array access. Observed in model received from Luigi & Simone.

ERROR: [XFORM 203-103] Cannot partition array 'pool2d_layer2_out.V' (firmware/mininet_CMDrFDeDe.cpp:77): array access out of bound (/home/hls4ml/FPGA/hls4ml_luigi/nnet_utils/nnet_pooling.h:171:8).
ERROR: [HLS 200-70] Pre-synthesis failed.
command 'ap_source' returned error code
    while executing
"source [lindex $::argv 1] "
    ("uplevel" body line 1)
    invoked from within
"uplevel \#0 { source [lindex $::argv 1] } "

Adding the simple check and dropping the extra rows/columns did not seem to affect latency.

Merge request reports

Loading