mirror of
https://github.com/opencv/opencv.git
synced 2025-06-13 04:52:53 +08:00
dnn(onnx): emit error in Shape for dynamic input
This commit is contained in:
parent
51e65db715
commit
88a18c8b6a
@ -2146,11 +2146,22 @@ void ONNXImporter::parseShape(LayerParams& layerParams, const opencv_onnx::NodeP
|
|||||||
CV_Assert(shapeIt != outShapes.end());
|
CV_Assert(shapeIt != outShapes.end());
|
||||||
const MatShape& inpShape = shapeIt->second;
|
const MatShape& inpShape = shapeIt->second;
|
||||||
|
|
||||||
Mat shapeMat(inpShape.size(), 1, CV_32S);
|
int dims = static_cast<int>(inpShape.size());
|
||||||
for (int j = 0; j < inpShape.size(); ++j)
|
Mat shapeMat(dims, 1, CV_32S);
|
||||||
shapeMat.at<int>(j) = inpShape[j];
|
bool isDynamicShape = false;
|
||||||
shapeMat.dims = 1;
|
for (int j = 0; j < dims; ++j)
|
||||||
|
{
|
||||||
|
int sz = inpShape[j];
|
||||||
|
isDynamicShape |= (sz == 0);
|
||||||
|
shapeMat.at<int>(j) = sz;
|
||||||
|
}
|
||||||
|
shapeMat.dims = 1; // FIXIT Mat 1D
|
||||||
|
|
||||||
|
if (isDynamicShape)
|
||||||
|
{
|
||||||
|
CV_LOG_ERROR(NULL, "DNN/ONNX(Shape): dynamic 'zero' shapes are not supported, input " << toString(inpShape, node_proto.input(0)));
|
||||||
|
CV_Assert(!isDynamicShape); // not supported
|
||||||
|
}
|
||||||
addConstant(layerParams.name, shapeMat);
|
addConstant(layerParams.name, shapeMat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user