support broadcast on axis > 1 for Expand

pull/23491/head
fengyuentau 2 years ago
parent f5a92cb43f
commit 88cacd35c5
  1. 5
      modules/dnn/src/onnx/onnx_importer.cpp

@ -2529,8 +2529,11 @@ void ONNXImporter::parseExpand(LayerParams& layerParams, const opencv_onnx::Node
node_proto.set_input(0, constParams.name); node_proto.set_input(0, constParams.name);
node_proto.set_input(1, srcName); node_proto.set_input(1, srcName);
} }
else if (broadcast_axes.size() == 1 && broadcast_axes[0] <= 1) else if (broadcast_axes.size() == 1)
{ {
// FIXME: this will end up creating massive amount of Identity nodes for broadcasting,
// for example, broadcast 1 to 256 needs 256 Identity nodes and 1 Concat node.
// Possible improvement is to use "Scale".
expandMid(layerParams.name, node_proto, srcName, targetShape[broadcast_axes[0]]); expandMid(layerParams.name, node_proto, srcName, targetShape[broadcast_axes[0]]);
layerParams.set("axis", broadcast_axes[0]); layerParams.set("axis", broadcast_axes[0]);

Loading…
Cancel
Save