From 2f36f8cb8d14933b8fae2d5b64e4716a736b7043 Mon Sep 17 00:00:00 2001 From: sjtubinlong Date: Sat, 14 Dec 2019 21:38:10 +0800 Subject: [PATCH] c++ inference: improve performance of mat flatten --- deploy/cpp/utils/utils.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/deploy/cpp/utils/utils.h b/deploy/cpp/utils/utils.h index 75d0b6c8..45ffde50 100644 --- a/deploy/cpp/utils/utils.h +++ b/deploy/cpp/utils/utils.h @@ -108,10 +108,11 @@ namespace utils { int rh = im.rows; int rw = im.cols; int rc = im.channels(); - int top_index = 0; + #pragma omp parallel for for (int h = 0; h < rh; ++h) { const uchar* ptr = im.ptr(h); int im_index = 0; + int top_index = h * rw * rc; for (int w = 0; w < rw; ++w) { for (int c = 0; c < rc; ++c) { float pixel = static_cast(ptr[im_index++]); -- GitLab