diff --git a/modules/dnn/src/layers/reduce_layer.cpp b/modules/dnn/src/layers/reduce_layer.cpp index b983a791c5..77d8898df4 100644 --- a/modules/dnn/src/layers/reduce_layer.cpp +++ b/modules/dnn/src/layers/reduce_layer.cpp @@ -425,7 +425,7 @@ public: dtype* p_dst = dst.ptr(); size_t main_index = start / last_unreduced_dim; - size_t loop = start / last_unreduced_dim; + size_t loop = start % last_unreduced_dim; size_t origin = unprojected_steps[main_index] + loop * last_unreduced_step; for (int i = start; i < end; ++i) { Op accumulator(n_reduce, p_src[origin + projected_steps[0]]);