From 6accb47c4588ab6f0c350117faf7f26e850446d2 Mon Sep 17 00:00:00 2001 From: "Soto Flores, Manuel" Date: Wed, 18 Sep 2019 18:04:31 -0700 Subject: [PATCH] src: cpu: avx2: add default case for jcp.nb_oc_blocking size Fixes cases for `jcp.nb_oc % {3,2} != 0` which resulted in incorrect output or assert triggering seg-fault. --- src/cpu/jit_avx2_conv_kernel_f32.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/cpu/jit_avx2_conv_kernel_f32.cpp b/src/cpu/jit_avx2_conv_kernel_f32.cpp index aba00f82589..8e9ea84a4ef 100644 --- a/src/cpu/jit_avx2_conv_kernel_f32.cpp +++ b/src/cpu/jit_avx2_conv_kernel_f32.cpp @@ -528,12 +528,19 @@ status_t jit_avx2_conv_fwd_kernel_f32::init_conf(jit_conv_conf_t &jcp, // adjust one of nb_oc_block, ur_w preserving to ur_w >= l_pad if (jcp.ur_w > jcp.l_pad && jcp.ur_w > 1) jcp.ur_w -= 1; - else - for (int b = 3; b > 1; b--) + else { + for (int b = 3; b > 1; b--) { if (jcp.nb_oc % b == 0) { jcp.nb_oc_blocking = b; break; } + } + if ((jcp.nb_oc_blocking + 1) * jcp.ur_w > num_avail_regs) { + // No optimal size for 'nb_oc_blocking' with regards to + // 'nb_oc', default to only unroll by 'ur_w'. + jcp.nb_oc_blocking = 1; + } + } } }