From 38e7ad799cb96ff2b7430fc0c8c7d9e57470131a Mon Sep 17 00:00:00 2001 From: gaoyuan Date: Mon, 11 Sep 2017 11:19:36 +0800 Subject: [PATCH] Set detection output to NULL --- paddle/gserver/layers/DetectionOutputLayer.cpp | 9 +++++++-- paddle/gserver/layers/DetectionUtil.cpp | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/paddle/gserver/layers/DetectionOutputLayer.cpp b/paddle/gserver/layers/DetectionOutputLayer.cpp index a1036ea866b..0cf0a92bf4b 100644 --- a/paddle/gserver/layers/DetectionOutputLayer.cpp +++ b/paddle/gserver/layers/DetectionOutputLayer.cpp @@ -139,8 +139,13 @@ void DetectionOutputLayer::forward(PassType passType) { allDecodedBBoxes, &allIndices); - numKept = numKept > 0 ? numKept : 1; - resetOutput(numKept, 7); + if (numKept > 0) { + resetOutput(numKept, 7); + } else { + MatrixPtr outV = getOutputValue(); + outV = NULL; + return; + } MatrixPtr outV = getOutputValue(); getDetectionOutput(confBuffer_->getData(), numKept, diff --git a/paddle/gserver/layers/DetectionUtil.cpp b/paddle/gserver/layers/DetectionUtil.cpp index 070bc0bce61..d83674f45a7 100644 --- a/paddle/gserver/layers/DetectionUtil.cpp +++ b/paddle/gserver/layers/DetectionUtil.cpp @@ -536,7 +536,6 @@ void getDetectionOutput(const real* confData, MatrixPtr outBuffer; Matrix::resizeOrCreate(outBuffer, numKept, 7, false, false); real* bufferData = outBuffer->getData(); - for (size_t i = 0; i < 7; i++) bufferData[i] = -1; size_t count = 0; for (size_t n = 0; n < batchSize; ++n) { for (map>::const_iterator it = allIndices[n].begin(); -- GitLab