mirror of
https://github.com/opencv/opencv.git
synced 2026-07-31 08:13:04 +04:00
Merge pull request #28000 from dkurt:d.kurtaev:reset_winograd_impl
### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request resolves https://github.com/opencv/opencv/issues/27580 - [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:
@@ -2788,4 +2788,47 @@ INSTANTIATE_TEST_CASE_P(TestLayerFusion, ConvolutionActivationEltwiseFusion, Com
|
||||
TestLayerFusion::dnnBackendsAndTargetsForFusionTests()
|
||||
));
|
||||
|
||||
TEST(ConvolutionWinograd, Accuracy)
|
||||
{
|
||||
Mat weights({2, 1, 3, 3}, CV_32F);
|
||||
randn(weights, 0, 1);
|
||||
|
||||
// Check convolution can switch between implementations on changed shape.
|
||||
auto getNet = [&]() {
|
||||
Net net;
|
||||
LayerParams lp;
|
||||
lp.name = "conv";
|
||||
lp.type = "Convolution";
|
||||
lp.set("kernel_size", 3);
|
||||
lp.set("num_output", 2);
|
||||
lp.set("pad", 0);
|
||||
lp.set("stride", 1);
|
||||
lp.set("bias_term", false);
|
||||
|
||||
lp.blobs.push_back(weights);
|
||||
net.addLayerToPrev(lp.name, lp.type, lp);
|
||||
return net;
|
||||
};
|
||||
|
||||
Mat inpSmall({1, 1, 5, 5}, CV_32F);
|
||||
Mat inpLarge({1, 1, 64, 64}, CV_32F);
|
||||
randn(inpSmall, 0, 1);
|
||||
randn(inpLarge, 0, 1);
|
||||
|
||||
Net net1 = getNet();
|
||||
Net net2 = getNet();
|
||||
net1.setInput(inpSmall);
|
||||
net2.setInput(inpLarge);
|
||||
Mat refSmall = net1.forward();
|
||||
Mat refLarge = net2.forward();
|
||||
|
||||
net1.setInput(inpLarge);
|
||||
net2.setInput(inpSmall);
|
||||
Mat outLarge = net1.forward();
|
||||
Mat outSmall = net2.forward();
|
||||
|
||||
normAssert(outSmall, refSmall, "Small input after large", 0.0, 0.0);
|
||||
normAssert(outLarge, refLarge, "Large input after small", 0.0, 0.0);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user