Skip to content

DNN: Optimization: Fuse Deconvolution -> BatchNorm - #13875

Merged
opencv-pushbot merged 1 commit into
opencv:3.4from
allnes:optimization_fuse
Mar 7, 2019
Merged

opencv-pushbot merged 1 commit into
opencv:3.4from
allnes:optimization_fuse

Conversation

@allnes

@allnes allnes commented Feb 20, 2019 •

Copy link
Copy Markdown
Member
force_builders=Custom
buildworker:Custom=linux-2
docker_image:Custom=ubuntu-openvino:16.04
test_opencl:Custom=ON
test_bigdata:Custom=1
test_filter:Custom=*
test_modules:Custom=dnn

{
double wi = w.at<float>(i);
weightsMultipliers[i] *= wi;
cv::multiply(originWeights.row(i), weightsMultipliers[i], weightsMat.row(i));

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.

That looks confusing. weightsMat is initialized with as weightsMat = (blobs[0].reshape(1, inpCn)).clone(); (with number of rows equals number of input channels) but in this loop we iterate over rows by number output channels.


if (!b.empty())
{
for (int i = 0; i < outCn; ++i) { biasesMat.at<float>(i) += b.at<float>(i); }

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.

Can we use cv::add or operator += instead?

@allnes
allnes changed the base branch from master to 3.4 February 21, 2019 09:23
@allnes
allnes force-pushed the optimization_fuse branch 2 times, most recently from f0442b3 to aa3143e Compare February 25, 2019 15:37
@allnes
allnes requested a review from dkurt February 25, 2019 15:38

void fuseWeights(const Mat& w_, const Mat& b_) CV_OVERRIDE
{
const int outCn = weightsMat.size[0] / (blobs[0].size[2] * blobs[0].size[3]);

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.

You can use numOutput member.

pad.width = pad_l;
pad.height = pad_t;

weightsMultipliers.assign(blobs[0].size[0], 1.0);

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.

Number of multipliers should be equal number of output channels (numOutput). However blobs[0] is a weights matrix with shape IOHW where I is a number of input channels and O is a number of output channels divided by group number. So it's better to use numOutput instead of raw shapes of weigths blob.

@allnes
allnes force-pushed the optimization_fuse branch 2 times, most recently from 7a5d2a0 to b8cc741 Compare February 27, 2019 09:30
@allnes
allnes requested a review from dkurt February 27, 2019 09:30
@allnes
allnes force-pushed the optimization_fuse branch 3 times, most recently from 033077e to 2e0acac Compare March 5, 2019 09:14
@@ -308,6 +308,12 @@ TEST_P(DNNTestNetwork, FastNeuralStyle_eccv16)
(backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16) ||
(backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD))

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.

please also check if backend == DNN_BACKEND_OPENCV && target == DNN_TARGET_OPENCL_FP16 and backend == DNN_BACKEND_INFERENCE_ENGINE && target == DNN_TARGET_MYRIAD configurations pass this test.

@allnes
allnes force-pushed the optimization_fuse branch 2 times, most recently from ee3e041 to 74574df Compare March 5, 2019 16:12

@dkurt dkurt 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.

Looks good to merge! Thanks!
I asked @allnes to disable FastNeuralStyle model tests for DLIE/OCL due a bug in the plugin.

@dkurt dkurt self-assigned this Mar 6, 2019
@allnes allnes changed the title DNN: Otimization: Fuse Deconvolution -> BatchNorm DNN: Optimization: Fuse Deconvolution -> BatchNorm Mar 6, 2019
@opencv-pushbot
opencv-pushbot merged commit 74574df into opencv:3.4 Mar 7, 2019
@alalek alalek mentioned this pull request Mar 11, 2019
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.

4 participants