for(int i = 0; i < outCn; i++ )
biasvec[i] = biasMat.at<float>(i);
}
+#ifdef HAVE_OPENCL
+ convolutionOp.release();
+#endif
}
bool setActivation(const Ptr<ActivationLayer>& layer)
};
#ifdef HAVE_OPENCL
+ void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
+ {
+ innerProductOp.release();
+ }
+
bool forward_ocl(InputArrayOfArrays inps, OutputArrayOfArrays outs, InputArrayOfArrays internals)
{
std::vector<UMat> inputs;
}
#ifdef HAVE_OPENCL
+ void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
+ {
+ lrnOp.release();
+ }
+
bool forward_ocl(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays internals)
{
std::vector<UMat> inputs;
}
getConvPoolPaddings(inp, out, kernel, stride, padMode, Size(1, 1), pad);
+
+#ifdef HAVE_OPENCL
+ poolOp.release();
+#endif
}
virtual bool supportBackend(int backendId)
#ifdef HAVE_OPENCL
virtual void finalize(const std::vector<Mat*> &inputs, std::vector<Mat> &outputs)
{
- OCL4DNNSoftmaxConfig config;
-
- config.in_shape = shape(*inputs[0]);
- config.axis = axisRaw;
- config.channels = inputs[0]->size[axisRaw];
- config.logsoftmax = logSoftMax;
-
- softmaxOp = Ptr<OCL4DNNSoftmax<float> >(new OCL4DNNSoftmax<float>(config));
+ softmaxOp.release();
}
bool forward_ocl(InputArrayOfArrays inps, OutputArrayOfArrays outs, OutputArrayOfArrays itns)
outs.getUMatVector(outputs);
itns.getUMatVector(internals);
+ if (softmaxOp.empty())
+ {
+ OCL4DNNSoftmaxConfig config;
+
+ config.in_shape = shape(inputs[0]);
+ config.axis = axisRaw;
+ config.channels = inputs[0].size[axisRaw];
+ config.logsoftmax = logSoftMax;
+
+ softmaxOp = Ptr<OCL4DNNSoftmax<float> >(new OCL4DNNSoftmax<float>(config));
+ }
+
UMat& src = inputs[0];
UMat& dstMat = outputs[0];
net.setPreferableBackend(DNN_BACKEND_DEFAULT);
net.setPreferableTarget(DNN_TARGET_OPENCL);
+ // Initialize network for a single image in the batch but test with batch size=2.
+ net.setInput(blobFromImage(Mat(224, 224, CV_8UC3)));
+ net.forward();
+
std::vector<Mat> inpMats;
inpMats.push_back( imread(_tf("googlenet_0.png")) );
inpMats.push_back( imread(_tf("googlenet_1.png")) );