mirror of
https://github.com/opencv/opencv.git
synced 2025-06-07 17:44:04 +08:00
integrate bias handling in ocl kernel
This commit is contained in:
parent
7919d04a9b
commit
83acb656f1
@ -455,13 +455,6 @@ public:
|
|||||||
ret = false;
|
ret = false;
|
||||||
break;
|
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;
|
if (ret) return true;
|
||||||
|
@ -97,15 +97,19 @@ bool OCL4DNNInnerProduct<Dtype>::Forward(const UMat& bottom,
|
|||||||
max_image_size);
|
max_image_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (use_half_ && bias_term_)
|
if (bias_term_) {
|
||||||
{
|
if (use_half_) {
|
||||||
UMat biasOneMat = UMat::ones(M_, 1, CV_32F);
|
UMat biasOneMat = UMat::ones(M_, 1, CV_32F);
|
||||||
UMat newbias, tmpTop;
|
UMat newbias, tmpTop;
|
||||||
|
|
||||||
convertFp16(bias, newbias);
|
convertFp16(bias, newbias);
|
||||||
convertFp16(top, tmpTop);
|
convertFp16(top, tmpTop);
|
||||||
cv::gemm(biasOneMat, newbias, 1, tmpTop, 1, tmpTop, 0);
|
cv::gemm(biasOneMat, newbias, 1, tmpTop, 1, tmpTop, 0);
|
||||||
convertFp16(tmpTop, top);
|
convertFp16(tmpTop, top);
|
||||||
|
} else {
|
||||||
|
UMat biasOnesMat = UMat::ones(M_, 1, CV_32F);
|
||||||
|
cv::gemm(biasOnesMat, bias, 1, top, 1, top, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
|
Loading…
Reference in New Issue
Block a user