|
|
|
@ -475,7 +475,8 @@ void ONNXImporter::populateNet() |
|
|
|
|
for (int j = 0; j < inpShape.size(); ++j) |
|
|
|
|
{ |
|
|
|
|
inpShape[j] = tensorShape.dim(j).dim_value(); |
|
|
|
|
if (!tensorShape.dim(j).dim_param().empty()) |
|
|
|
|
// NHW, NCHW(NHWC), NCDHW(NDHWC); do not set this flag if only N is dynamic
|
|
|
|
|
if (!tensorShape.dim(j).dim_param().empty() && !(j == 0 && inpShape.size() >= 3)) |
|
|
|
|
hasDynamicShapes = true; |
|
|
|
|
} |
|
|
|
|
if (!inpShape.empty() && !hasDynamicShapes) |
|
|
|
@ -1407,6 +1408,16 @@ void ONNXImporter::parseMul(LayerParams& layerParams, const opencv_onnx::NodePro |
|
|
|
|
//Replace input to Power
|
|
|
|
|
node_proto.set_input(1, powerParams.name); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
const MatShape& broadShape = outShapes[node_proto.input(1)]; |
|
|
|
|
const size_t outShapeSize = outShapes[node_proto.input(0)].size(); |
|
|
|
|
const size_t diff = outShapeSize - broadShape.size(); |
|
|
|
|
|
|
|
|
|
size_t axis; |
|
|
|
|
for (axis = diff; axis < broadShape.size() && broadShape[axis - diff] == 1; ++axis) {} |
|
|
|
|
|
|
|
|
|
CV_Assert(axis != outShapeSize); |
|
|
|
|
layerParams.set("axis", static_cast<int>(axis)); |
|
|
|
|
layerParams.type = "Scale"; |
|
|
|
|
} |
|
|
|
|
addLayer(layerParams, node_proto); |
|
|
|
|