Commit 64a9e923 authored by Dmitry Kurtaev's avatar Dmitry Kurtaev Committed by Alexander Alekhin

Merge pull request #10466 from dkurt:reduce_umat_try_2

* UMat blobs are wrapped

* Replace getUMat and getMat at OpenCLBackendWrapper
parent b6075e11
This diff is collapsed.
......@@ -709,6 +709,10 @@ public:
inps.getUMatVector(inputs);
outs.getUMatVector(outputs);
CV_Assert(outputs.size() == 1);
for (int i = 0; i < inputs.size(); ++i)
CV_Assert(inputs[i].u != outputs[0].u);
int group = inputs[0].size[1] / umat_blobs[0].size[1];
if (convolutionOp.empty())
......@@ -913,7 +917,9 @@ public:
name.c_str(), inputs[0]->size[0], inputs[0]->size[1], inputs[0]->size[2], inputs[0]->size[3],
kernel.width, kernel.height, pad.width, pad.height,
stride.width, stride.height, dilation.width, dilation.height);*/
CV_Assert(inputs.size() == (size_t)1 && inputs[0]->size[1] % blobs[0].size[1] == 0);
CV_Assert(inputs.size() == (size_t)1, inputs[0]->size[1] % blobs[0].size[1] == 0,
outputs.size() == 1, inputs[0]->data != outputs[0].data);
int ngroups = inputs[0]->size[1]/blobs[0].size[1];
CV_Assert(outputs[0].size[1] % ngroups == 0);
int k, outCn = blobs[0].size[0];
......
......@@ -303,6 +303,14 @@ OCL_TEST(Reproducibility_ResNet50, Accuracy)
Mat ref = blobFromNPY(_tf("resnet50_prob.npy"));
normAssert(ref, out);
UMat out_umat;
net.forward(out_umat);
normAssert(ref, out_umat, "out_umat");
std::vector<UMat> out_umats;
net.forward(out_umats);
normAssert(ref, out_umats[0], "out_umat_vector");
}
TEST(Reproducibility_SqueezeNet_v1_1, Accuracy)
......@@ -331,9 +339,14 @@ OCL_TEST(Reproducibility_SqueezeNet_v1_1, Accuracy)
Mat input = blobFromImage(imread(_tf("googlenet_0.png")), 1.0f, Size(227,227), Scalar(), false);
ASSERT_TRUE(!input.empty());
net.setInput(input);
// Firstly set a wrong input blob and run the model to receive a wrong output.
net.setInput(input * 2.0f);
Mat out = net.forward();
// Then set a correct input blob to check CPU->GPU synchronization is working well.
net.setInput(input);
out = net.forward();
Mat ref = blobFromNPY(_tf("squeezenet_v1.1_prob.npy"));
normAssert(ref, out);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment