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 <olivier.hotel@orange.com>
This commit is contained in:
Olivier Hotel 2023-05-30 10:21:27 +02:00
parent 1457320702
commit 0442c6fa81

View File

@ -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<int>(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<int>(i);
axis = normalize_axis(axis, inpShape.size());
CV_CheckLE(axis, static_cast<int>(inpShape.size()), "Squeeze axis");
maskedAxes[axis] = inpShape[axis] == 1;
}