Skip to content

Commit

Permalink
remove old nms_util.h
Browse files Browse the repository at this point in the history
  • Loading branch information
zhiboniu committed Aug 3, 2022
1 parent a0caeae commit a93d3a3
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 491 deletions.
5 changes: 3 additions & 2 deletions paddle/fluid/operators/detection/generate_proposals_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_version_registry.h"
#include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/detection/nms_util.h"
#include "paddle/phi/kernels/funcs/detection/nms_util.h"
#include "paddle/phi/kernels/funcs/gather.h"
#include "paddle/phi/kernels/funcs/math_function.h"

Expand Down Expand Up @@ -251,7 +251,8 @@ class GenerateProposalsKernel : public framework::OpKernel<T> {
return std::make_pair(bbox_sel, scores_filter);
}

Tensor keep_nms = NMS<T>(ctx, &bbox_sel, &scores_filter, nms_thresh, eta);
Tensor keep_nms =
phi::funcs::NMS<T>(ctx, &bbox_sel, &scores_filter, nms_thresh, eta);

if (post_nms_top_n > 0 && post_nms_top_n < keep_nms.numel()) {
keep_nms.Resize({post_nms_top_n});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ limitations under the License. */
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_version_registry.h"
#include "paddle/fluid/operators/detection/bbox_util.h"
#include "paddle/fluid/operators/detection/nms_util.h"
#include "paddle/phi/infermeta/multiary.h"
#include "paddle/phi/kernels/funcs/detection/nms_util.h"
#include "paddle/phi/kernels/funcs/gather.h"
#include "paddle/phi/kernels/funcs/math_function.h"

Expand Down
277 changes: 0 additions & 277 deletions paddle/fluid/operators/detection/generate_proposals_v2_op.cu

This file was deleted.

31 changes: 16 additions & 15 deletions paddle/fluid/operators/detection/locality_aware_nms_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ limitations under the License. */
#include <glog/logging.h>

#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/operators/detection/nms_util.h"
#include "paddle/phi/kernels/funcs/detection/nms_util.h"

namespace paddle {
namespace operators {
Expand Down Expand Up @@ -118,15 +118,15 @@ void GetMaxScoreIndexWithLocalityAware(
if (index > -1) {
T overlap = T(0.);
if (box_size == 4) {
overlap = JaccardOverlap<T>(
overlap = phi::funcs::JaccardOverlap<T>(
bbox_data + i * box_size, bbox_data + index * box_size, normalized);
}
// 8: [x1 y1 x2 y2 x3 y3 x4 y4] or 16, 24, 32
if (box_size == 8 || box_size == 16 || box_size == 24 || box_size == 32) {
overlap = PolyIoU<T>(bbox_data + i * box_size,
bbox_data + index * box_size,
box_size,
normalized);
overlap = phi::funcs::PolyIoU<T>(bbox_data + i * box_size,
bbox_data + index * box_size,
box_size,
normalized);
}

if (overlap > nms_threshold) {
Expand Down Expand Up @@ -156,7 +156,7 @@ void GetMaxScoreIndexWithLocalityAware(
// Sort the score pair according to the scores in descending order
std::stable_sort(sorted_indices->begin(),
sorted_indices->end(),
SortScorePairDescend<int>);
phi::funcs::SortScorePairDescend<int>);
// Keep top_k scores if needed.
if (top_k > -1 && top_k < static_cast<int>(sorted_indices->size())) {
sorted_indices->resize(top_k);
Expand Down Expand Up @@ -207,17 +207,18 @@ class LocalityAwareNMSKernel : public framework::OpKernel<T> {
T overlap = T(0.);
// 4: [xmin ymin xmax ymax]
if (box_size == 4) {
overlap = JaccardOverlap<T>(bbox_data + idx * box_size,
bbox_data + kept_idx * box_size,
normalized);
overlap =
phi::funcs::JaccardOverlap<T>(bbox_data + idx * box_size,
bbox_data + kept_idx * box_size,
normalized);
}
// 8: [x1 y1 x2 y2 x3 y3 x4 y4] or 16, 24, 32
if (box_size == 8 || box_size == 16 || box_size == 24 ||
box_size == 32) {
overlap = PolyIoU<T>(bbox_data + idx * box_size,
bbox_data + kept_idx * box_size,
box_size,
normalized);
overlap = phi::funcs::PolyIoU<T>(bbox_data + idx * box_size,
bbox_data + kept_idx * box_size,
box_size,
normalized);
}
keep = overlap <= adaptive_threshold;
} else {
Expand Down Expand Up @@ -290,7 +291,7 @@ class LocalityAwareNMSKernel : public framework::OpKernel<T> {
// Keep top k results per image.
std::stable_sort(score_index_pairs.begin(),
score_index_pairs.end(),
SortScorePairDescend<std::pair<int, int>>);
phi::funcs::SortScorePairDescend<std::pair<int, int>>);
score_index_pairs.resize(keep_top_k);

// Store the new indices.
Expand Down
2 changes: 1 addition & 1 deletion paddle/fluid/operators/detection/matrix_nms_op.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ limitations under the License. */
#include "paddle/fluid/framework/infershape_utils.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/framework/op_version_registry.h"
#include "paddle/fluid/operators/detection/nms_util.h"
#include "paddle/phi/infermeta/binary.h"
#include "paddle/phi/kernels/funcs/detection/nms_util.h"

namespace paddle {
namespace operators {
Expand Down
Loading

0 comments on commit a93d3a3

Please sign in to comment.