Skip to content

Clone convolution layer weights only for fusion - #13716

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
dkurt:dnn_conv_weights_clone
Feb 1, 2019
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
dkurt:dnn_conv_weights_clone

Conversation

@dkurt

@dkurt dkurt commented Jan 29, 2019

Copy link
Copy Markdown
Member

This pullrequest changes

Move convolution weights cloning to fusion phase to reduce top memory consumption.

Model w/o PR with PR
AlexNet 398 MB 398 MB (x1.00)
ResNet-50 222 MB 222 MB (x1.00)
SqueezeNet v1.1 35 MB 30.5 MB (x0.86)
MobileNet-SSD (Caffe) 73 MB 50.3 MB (x0.68)
MobileNet-SSD v1 (TensorFlow) 83.3 MB 58.8 MB (x0.70)

Sample (use /usr/bin/time --verbose)

#include <opencv2/opencv.hpp>

using namespace cv;
using namespace cv::dnn;

std::string keys =
    "{ model     | |  }"
    "{ proto     | |  }"
    "{ size     | |  }";


int main(int argc, char** argv) {
  CommandLineParser parser(argc, argv, keys);

  const std::string model = parser.get<String>("model");
  const std::string proto = parser.get<String>("proto");
  const int size = parser.get<int>("size");

  int blobSize[] = {1, 3, size, size};
  Mat blob(4, &blobSize[0], CV_32F);

  Net net = readNet(model, proto);
  net.setInput(blob);
  net.forward();

  return 0;
}

@alalek alalek left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@opencv-pushbot
opencv-pushbot merged commit ac262f5 into opencv:3.4 Feb 1, 2019
@alalek alalek mentioned this pull request Feb 1, 2019
@dkurt
dkurt deleted the dnn_conv_weights_clone branch May 6, 2019 05:49
SavyaSanchi-Sharma pushed a commit to SavyaSanchi-Sharma/opencv that referenced this pull request Jul 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants