Skip to content

Commit 55260a8

Browse files
committed
reshape mat before doing computation in fc layer
Signed-off-by: Li Peng <peng.li@intel.com>
1 parent e89501a commit 55260a8

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

modules/dnn/src/layers/fully_connected_layer.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,13 @@ class FullyConnectedLayerImpl : public InnerProductLayer
286286
UMat biasOnesMat = UMat::ones(outerSize, 1, umat_blobs[0].type());
287287
for (size_t i = 0; i < inputs.size(); i++)
288288
{
289-
UMat& srcMat = inputs[i];
290-
UMat& dstMat = outputs[i];
289+
MatShape inshape, outshape;
290+
inshape = shape(outerSize, innerSize);
291+
outshape = shape(outerSize, numOutput);
292+
293+
UMat srcMat, dstMat;
294+
srcMat = inputs[i].reshape(1, inshape.size(), &inshape[0]);
295+
dstMat = outputs[i].reshape(1, outshape.size(), &outshape[0]);
291296
dstMat.setTo(0.0f);
292297

293298
if (!innerProductOp->Forward(srcMat, umat_blobs[0], (bias) ? umat_blobs[1] : UMat(), dstMat))

0 commit comments

Comments
 (0)