mirror of
https://github.com/opencv/opencv.git
synced 2025-08-06 14:36:36 +08:00
Merge pull request #24101 from LaurentBerger:I24076
Invalid memory access fix for ONNX split layer parser #24076 #24101 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work https://github.com/opencv/opencv/issues/24076 - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
parent
5466fd2606
commit
2ff16d4c45
@ -1385,13 +1385,19 @@ void ONNXImporter::parseSplit(LayerParams& layerParams, const opencv_onnx::NodeP
|
||||
CV_Assert(constBlobs.find(node_proto.input(1)) != constBlobs.end());
|
||||
Mat splitsBlob = getBlob(node_proto, 1);
|
||||
int splitSize = splitsBlob.total();
|
||||
|
||||
std::vector<int> slicePoints(splitSize - 1, splitsBlob.at<int>(0));
|
||||
for (int i = 1; i < splitSize - 1; ++i)
|
||||
if (splitSize == 1)
|
||||
{
|
||||
slicePoints[i] = slicePoints[i - 1] + splitsBlob.at<int>(i);
|
||||
layerParams.set("num_split", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<int> slicePoints(splitSize - 1, splitsBlob.at<int>(0));
|
||||
for (int i = 1; i < splitSize - 1; ++i)
|
||||
{
|
||||
slicePoints[i] = slicePoints[i - 1] + splitsBlob.at<int>(i);
|
||||
}
|
||||
layerParams.set("slice_point", DictValue::arrayInt(&slicePoints[0], slicePoints.size()));
|
||||
}
|
||||
layerParams.set("slice_point", DictValue::arrayInt(&slicePoints[0], slicePoints.size()));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user