Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upGitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
Reduce top memory consumption of dnn module for FP16 precision #13413
Comments
|
Is this issue still open? I would like to work on this issue |
|
anybody working on this issue? |
|
I want to work on this issue @dkurt |
|
Feel free to propose solution by opening a pull request |


To reduce top memory consumption of dnn module usage we can achieve approximately x2 less memory usage for networks which will be executed with
DNN_TARGET_OPENCL_FP16orDNN_TARGET_MYRIAD.For now it loads all the weights in FP32 precision and performs FP32->FP16 conversion for mentioned targets. For models whom weights size more than internal allocations for intermediate blobs, we can reduce top memory consumption converting the weights to FP16 during import.
There are several questions that must be resolved:
Some layers which are failed to execute with
DNN_BACKEND_OPENCVandDNN_TARGET_OPENCL_FP16fallback toDNN_TARGET_OPENCLand then toDNN_TARGET_CPU. We need to manage it and keep FP32 weights.For now it works in this way:
And we need to say importers about the desired precision earlier.
2.1. Solution 1: An extra flag to
readNetwith target. (Or backend and target?)2.2. Solution 2: Create methods such
Net::readFromCaffeand specify target before import:However it's not so obvious for user as the first solution.
Precision of this approach won't be the same as FP32->FP16 path because now all the weights fusions are made in FP32.
It'd be great research to study dynamics of top memory consumption of dnn module for a single forward pass use case over different versions. There are several big PRs which made some changes in this topic: opencv/opencv_contrib#1205, #11461 (just ones I found in my logs), #9389 (closed for a while).