mirror of
https://github.com/opencv/opencv.git
synced 2026-12-01 13:48:53 -06:00
Merge pull request #25181 from dkurt:release_conv_weights
Release convolution weightsMat after usage #25181 ### Pull Request Readiness Checklist related (but not resolved): https://github.com/opencv/opencv/issues/24134 Minor memory footprint improvement. Also, adds a test for VmHWM. RAM top memory usage (-230MB) | YOLOv3 (237MB file) | 4.x | PR | |---------------------|---------|---------| | no winograd | 808 MB | 581 MB | | winograd | 1985 MB | 1750 MB | 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 - [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:
@@ -1299,6 +1299,10 @@ public:
|
||||
fastConvImpl = initFastConv(weightsMat, &biasvec[0], ngroups, K, C, kernel_size, strides,
|
||||
dilations, pads_begin, pads_end, conv_dim,
|
||||
preferableTarget == DNN_TARGET_CPU_FP16, canUseWinograd);
|
||||
// This is legal to release weightsMat here as this is not used anymore for
|
||||
// OpenCV inference. If network needs to be reinitialized (new shape, new backend)
|
||||
// a new version of weightsMat is created at .finalize() from original weights
|
||||
weightsMat.release();
|
||||
}
|
||||
|
||||
runFastConv(inputs[0], outputs[0], fastConvImpl, nstripes, activ, reluslope, fusedAdd);
|
||||
@@ -1405,6 +1409,7 @@ public:
|
||||
params.set("input_zeropoint", inputZp);
|
||||
params.set("input_scale", inputScale);
|
||||
|
||||
Mat weightsMat = blobs[0].reshape(1, numOutput);
|
||||
Mat weightsQuantized(weightsMat.rows, weightsMat.cols, CV_8S);
|
||||
Mat biasQuantized(1, numOutput, CV_32S);
|
||||
Mat outputMultiplier(1, numOutput, CV_32F);
|
||||
|
||||
Reference in New Issue
Block a user