From 0442c6fa8111618eec23ffbb605694a9eb501332 Mon Sep 17 00:00:00 2001 From: Olivier Hotel Date: Tue, 30 May 2023 10:21:27 +0200 Subject: [PATCH] Addition of normalize_axis to ONNXImporter::parseSqueeze to support negative values for the axes attribut. Negative values are part of the ONNX optset>=11. Signed-off-by: Olivier Hotel --- modules/dnn/src/onnx/onnx_importer.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/modules/dnn/src/onnx/onnx_importer.cpp b/modules/dnn/src/onnx/onnx_importer.cpp index 508ba0299e..46ee70aa5b 100644 --- a/modules/dnn/src/onnx/onnx_importer.cpp +++ b/modules/dnn/src/onnx/onnx_importer.cpp @@ -2147,6 +2147,7 @@ void ONNXImporter::parseSqueeze(LayerParams& layerParams, const opencv_onnx::Nod for (int i = 0; i < axes_dict.size(); ++i) { int axis = axes_dict.getIntValue(i); + axis = normalize_axis(axis, inpShape.size()); CV_CheckLE(axis, static_cast(inpShape.size()), "Squeeze axis"); maskedAxes[axis] = inpShape[axis] == 1; } @@ -2162,6 +2163,7 @@ void ONNXImporter::parseSqueeze(LayerParams& layerParams, const opencv_onnx::Nod for (int i = 0; i < axesLen; i++) { int axis = axesMat.at(i); + axis = normalize_axis(axis, inpShape.size()); CV_CheckLE(axis, static_cast(inpShape.size()), "Squeeze axis"); maskedAxes[axis] = inpShape[axis] == 1; }