From a421f479a23670e743005af2e9ba38eb8dcd6268 Mon Sep 17 00:00:00 2001 From: yangyaming Date: Thu, 15 Jun 2017 17:07:12 +0800 Subject: [PATCH] Follow comments. --- paddle/gserver/layers/DetectionUtil.cpp | 20 +++++++++++--------- paddle/gserver/layers/DetectionUtil.h | 10 ++++------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/paddle/gserver/layers/DetectionUtil.cpp b/paddle/gserver/layers/DetectionUtil.cpp index e9295edb6..3e61adc66 100644 --- a/paddle/gserver/layers/DetectionUtil.cpp +++ b/paddle/gserver/layers/DetectionUtil.cpp @@ -23,8 +23,9 @@ size_t appendWithPermute(const Matrix& inMatrix, size_t outOffset, size_t batchSize, Matrix& outMatrix, - PermMode permMode, - bool useGpu) { + PermMode permMode) { + CHECK_EQ(inMatrix.useGpu(), outMatrix.useGpu()); + bool useGpu = inMatrix.useGpu(); if (permMode == kNCHWToNHWC) { size_t inElementCnt = inMatrix.getElementCnt(); size_t channels = inElementCnt / (height * width * batchSize); @@ -58,8 +59,9 @@ size_t decomposeWithPermute(const Matrix& inMatrix, size_t inOffset, size_t batchSize, Matrix& outMatrix, - PermMode permMode, - bool useGpu) { + PermMode permMode) { + CHECK_EQ(inMatrix.useGpu(), outMatrix.useGpu()); + bool useGpu = inMatrix.useGpu(); if (permMode == kNHWCToNCHW) { size_t outElementCnt = outMatrix.getElementCnt(); size_t channels = outElementCnt / (height * width * batchSize); @@ -98,17 +100,17 @@ real jaccardOverlap(const NormalizedBBox& bbox1, const NormalizedBBox& bbox2) { real interWidth = interXMax - interXMin; real interHeight = interYMax - interYMin; - real interSize = interWidth * interHeight; + real interArea = interWidth * interHeight; - real bboxSize1 = bbox1.getSize(); - real bboxSize2 = bbox2.getSize(); + real bboxArea1 = bbox1.getArea(); + real bboxArea2 = bbox2.getArea(); - return interSize / (bboxSize1 + bboxSize2 - interSize); + return interArea / (bboxArea1 + bboxArea2 - interArea); } } void encodeBBoxWithVar(const NormalizedBBox& priorBBox, - const vector priorBBoxVar, + const vector& priorBBoxVar, const NormalizedBBox& gtBBox, vector& outVec) { real priorBBoxWidth = priorBBox.getWidth(); diff --git a/paddle/gserver/layers/DetectionUtil.h b/paddle/gserver/layers/DetectionUtil.h index 263dea001..fe4f9f075 100644 --- a/paddle/gserver/layers/DetectionUtil.h +++ b/paddle/gserver/layers/DetectionUtil.h @@ -40,7 +40,7 @@ struct BBoxBase { T getCenterY() const { return (yMin + yMax) / 2; } - T getSize() const { return getWidth() * getHeight(); } + T getArea() const { return getWidth() * getHeight(); } // coordinate of bounding box T xMin; @@ -67,8 +67,7 @@ size_t appendWithPermute(const Matrix& inMatrix, size_t outOffset, size_t batchSize, Matrix& outMatrix, - PermMode permMode, - bool useGpu); + PermMode permMode); /** * @brief First permute input maxtrix then decompose to output @@ -80,8 +79,7 @@ size_t decomposeWithPermute(const Matrix& inMatrix, size_t offset, size_t batchSize, Matrix& outMatrix, - PermMode permMode, - bool useGpu); + PermMode permMode); /** * @brief Compute jaccard overlap between two bboxes. @@ -99,7 +97,7 @@ real jaccardOverlap(const NormalizedBBox& bbox1, const NormalizedBBox& bbox2); * @param outVec Output vector */ void encodeBBoxWithVar(const NormalizedBBox& priorBBox, - const vector priorBBoxVar, + const vector& priorBBoxVar, const NormalizedBBox& gtBBox, vector& outVec); -- GitLab