nms.h 854 Bytes
Newer Older
1
#pragma once
2
#include "cpu/vision_cpu.h"
3
4

#ifdef WITH_CUDA
5
#include "autocast.h"
6
#include "cuda/vision_cuda.h"
7
#endif
8
9
10
#ifdef WITH_HIP
#include "hip/vision_cuda.h"
#endif
11

12
// nms dispatch nexus
13
14
15
at::Tensor nms(
    const at::Tensor& dets,
    const at::Tensor& scores,
16
    const double iou_threshold) {
17
18
19
20
21
  static auto op = c10::Dispatcher::singleton()
                       .findSchemaOrThrow("torchvision::nms", "")
                       .typed<decltype(nms)>();
  return op.call(dets, scores, iou_threshold);
}
22

23
24
25
26
27
28
29
30
31
32
#ifdef WITH_CUDA
at::Tensor nms_autocast(
    const at::Tensor& dets,
    const at::Tensor& scores,
    const double iou_threshold) {
  c10::impl::ExcludeDispatchKeyGuard no_autocast(c10::DispatchKey::Autocast);
  return nms(
      autocast::_cast(at::kFloat, dets),
      autocast::_cast(at::kFloat, scores),
      iou_threshold);
33
}
34
#endif