Skip to content

Commit 743f82c

Browse files
committed
Removed an extra reallocation of networks every setBlob call.
1 parent fa94c16 commit 743f82c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

modules/dnn/src/dnn.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -604,10 +604,10 @@ void Net::setBlob(String outputName, const Mat &blob_)
604604

605605
LayerData &ld = impl->layers[pin.lid];
606606
ld.outputBlobs.resize( std::max(pin.oid+1, (int)ld.requiredOutputs.size()) );
607-
MatSize prevShape = ld.outputBlobs[pin.oid].size;
607+
bool oldShape = ld.outputBlobs[pin.oid].size == blob_.size;
608608
ld.outputBlobs[pin.oid] = blob_.clone();
609609

610-
impl->netWasAllocated = impl->netWasAllocated && prevShape == blob_.size;
610+
impl->netWasAllocated = impl->netWasAllocated && oldShape;
611611
}
612612

613613
Mat Net::getBlob(String outputName)

0 commit comments

Comments
 (0)