mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
Merge pull request #24840 from fengyuentau:ocl_innerproduct
dnn (opencl): integrate bias handling in the inner product opencl kernel
This commit is contained in:
commit
97c418ab86
@ -455,13 +455,6 @@ public:
|
||||
ret = false;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!use_half && bias && (outerSize > 1))
|
||||
{
|
||||
UMat biasOnesMat = UMat::ones(outerSize, 1, umat_blobs[0].type());
|
||||
UMat& biases = umat_blobs[1];
|
||||
cv::gemm(biasOnesMat, biases, 1, dstMat, 1, dstMat, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (ret) return true;
|
||||
|
@ -97,8 +97,8 @@ bool OCL4DNNInnerProduct<Dtype>::Forward(const UMat& bottom,
|
||||
max_image_size);
|
||||
}
|
||||
|
||||
if (use_half_ && bias_term_)
|
||||
{
|
||||
if (bias_term_) {
|
||||
if (use_half_) {
|
||||
UMat biasOneMat = UMat::ones(M_, 1, CV_32F);
|
||||
UMat newbias, tmpTop;
|
||||
|
||||
@ -106,6 +106,10 @@ bool OCL4DNNInnerProduct<Dtype>::Forward(const UMat& bottom,
|
||||
convertFp16(top, tmpTop);
|
||||
cv::gemm(biasOneMat, newbias, 1, tmpTop, 1, tmpTop, 0);
|
||||
convertFp16(tmpTop, top);
|
||||
} else {
|
||||
UMat biasOnesMat = UMat::ones(M_, 1, CV_32F);
|
||||
cv::gemm(biasOnesMat, bias, 1, top, 1, top, 0);
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
Loading…
Reference in New Issue
Block a user