mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -2906,4 +2906,47 @@ TEST(Layer_Size, onnx_0d_scalar)
|
||||
EXPECT_EQ(outs[0].at<int64_t>(0), 1);
|
||||
}
|
||||
|
||||
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