diff options
Diffstat (limited to 'modules/dnn/src/layers/reshape_layer.cpp')
-rw-r--r-- | modules/dnn/src/layers/reshape_layer.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/modules/dnn/src/layers/reshape_layer.cpp b/modules/dnn/src/layers/reshape_layer.cpp index 65a81c7820..c9e632dd29 100644 --- a/modules/dnn/src/layers/reshape_layer.cpp +++ b/modules/dnn/src/layers/reshape_layer.cpp @@ -82,17 +82,26 @@ static void computeShapeByReshapeMask(const MatShape &srcShape, { if (matched) { - if (i == 0 || total(srcShape, i, srcRange.end) != maskTotal) + if (total(srcShape, i, srcRange.end) != maskTotal) { srcRange.start = i + 1; break; } + else if (i == 0) + { + srcRange.start = 0; + break; + } } else { matched = total(srcShape, i, srcRange.end) == maskTotal; } } + while (total(srcShape, srcRange.start, srcRange.end) != maskTotal && srcRange.start > 0) + { + srcRange.start -= 1; + } CV_Assert(total(srcShape, srcRange.start, srcRange.end) == maskTotal); } |