-
Notifications
You must be signed in to change notification settings - Fork 13
/
bnmorph_getcorpts.cpp
57 lines (51 loc) · 1.64 KB
/
bnmorph_getcorpts.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#include <torch/extension.h>
#include <ATen/ATen.h>
#include <vector>
// CUDA forward declarations
std::vector<torch::Tensor> bnmorph_cuda(
torch::Tensor binMapsrc,
torch::Tensor binMapdst,
torch::Tensor xx,
torch::Tensor yy,
torch::Tensor sxx,
torch::Tensor syy,
torch::Tensor cxx,
torch::Tensor cyy,
float pixel_distance_weight,
float alpha_distance_weight,
float pixel_mulline_distance_weight,
float alpha_padding
);
// C++ interface
// NOTE: AT_ASSERT has become AT_CHECK on master after 0.4.
#define CHECK_CUDA(x) AT_ASSERTM(x.type().is_cuda(), #x " must be a CUDA tensor")
#define CHECK_CONTIGUOUS(x) AT_ASSERTM(x.is_contiguous(), #x " must be contiguous")
#define CHECK_INPUT(x) CHECK_CUDA(x); CHECK_CONTIGUOUS(x)
std::vector<torch::Tensor> bnmorph(
torch::Tensor binMapsrc,
torch::Tensor binMapdst,
torch::Tensor xx,
torch::Tensor yy,
torch::Tensor sxx,
torch::Tensor syy,
torch::Tensor cxx,
torch::Tensor cyy,
float pixel_distance_weight,
float alpha_distance_weight,
float pixel_mulline_distance_weight,
float alpha_padding
) {
CHECK_INPUT(binMapsrc)
CHECK_INPUT(binMapdst)
CHECK_INPUT(xx)
CHECK_INPUT(yy)
CHECK_INPUT(sxx)
CHECK_INPUT(syy)
CHECK_INPUT(cxx)
CHECK_INPUT(cyy)
std::vector<torch::Tensor> results_bindings = bnmorph_cuda(binMapsrc, binMapdst, xx, yy, sxx, syy, cxx, cyy, pixel_distance_weight, alpha_distance_weight, pixel_mulline_distance_weight, alpha_padding);
return results_bindings;
}
PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
m.def("bnmorph", &bnmorph, "a more general Beier–Neely morph");
}