1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-30 07:43:03 +04:00

Merge pull request #28643 from Prasadayus:fix-gather-cast-axis-4x

DNN/ONNX: Preserve axis attribute in GatherCastSubgraph fusion
This commit is contained in:
Alexander Smorkalov
2026-03-13 11:46:19 +03:00
committed by GitHub
+20 -1
View File
@@ -1278,14 +1278,33 @@ public:
}
}
}
// extract axis from original Gather node
axis = 0;
opencv_onnx::NodeProto* origGatherNode =
inpNode.dynamicCast<ONNXNodeWrapper>()->node;
for (int i = 0; i < origGatherNode->attribute_size(); i++) {
opencv_onnx::AttributeProto attr = origGatherNode->attribute(i);
if (attr.name() == "axis")
axis = attr.i();
}
}
}
}
return retVal;
}
virtual void finalize(const Ptr<ImportGraphWrapper>& net,
const Ptr<ImportNodeWrapper>& fusedNode,
std::vector<Ptr<ImportNodeWrapper> >& /*inputs*/) CV_OVERRIDE
{
opencv_onnx::NodeProto* node = fusedNode.dynamicCast<ONNXNodeWrapper>()->node;
opencv_onnx::AttributeProto* new_attr = node->add_attribute();
new_attr->set_name("axis");
new_attr->set_i(axis);
}
private:
int cast, gather;
int cast, gather, axis;
};
/* Constant folding shape for Expand.