Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/utils/nms_rotated/src/nms_rotated_ext.cpp
Views: 475
// Modified from1// https://github.com/facebookresearch/detectron2/tree/master/detectron2/layers/csrc/nms_rotated2// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved3#include <ATen/ATen.h>4#include <torch/extension.h>567#ifdef WITH_CUDA8at::Tensor nms_rotated_cuda(9const at::Tensor& dets,10const at::Tensor& scores,11const float iou_threshold);1213at::Tensor poly_nms_cuda(14const at::Tensor boxes,15float nms_overlap_thresh);16#endif1718at::Tensor nms_rotated_cpu(19const at::Tensor& dets,20const at::Tensor& scores,21const float iou_threshold);222324inline at::Tensor nms_rotated(25const at::Tensor& dets,26const at::Tensor& scores,27const float iou_threshold) {28assert(dets.device().is_cuda() == scores.device().is_cuda());29if (dets.device().is_cuda()) {30#ifdef WITH_CUDA31return nms_rotated_cuda(32dets.contiguous(), scores.contiguous(), iou_threshold);33#else34AT_ERROR("Not compiled with GPU support");35#endif36}37return nms_rotated_cpu(dets.contiguous(), scores.contiguous(), iou_threshold);38}394041inline at::Tensor nms_poly(42const at::Tensor& dets,43const float iou_threshold) {44if (dets.device().is_cuda()) {45#ifdef WITH_CUDA46if (dets.numel() == 0)47return at::empty({0}, dets.options().dtype(at::kLong).device(at::kCPU));48return poly_nms_cuda(dets, iou_threshold);49#else50AT_ERROR("POLY_NMS is not compiled with GPU support");51#endif52}53AT_ERROR("POLY_NMS is not implemented on CPU");54}5556PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {57m.def("nms_rotated", &nms_rotated, "nms for rotated bboxes");58m.def("nms_poly", &nms_poly, "nms for poly bboxes");59}606162