MCPcopy Create free account
hub / github.com/EnyaHermite/PicassoPlus / FarthestPointSample

Function FarthestPointSample

picasso/point/pi_modules/source/sample.cpp:20–48  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18
19
20torch::Tensor FarthestPointSample(
21 torch::Tensor xyz_in, // concatenated point xyz: concat_Np * 3
22 torch::Tensor nv_in, // number of points in each input batch sample: batch_size
23 torch::Tensor nv_out) // number of points in each output batch sample: batch_size
24{
25 CHECK_INPUT(xyz_in,2);
26 CHECK_INPUT(nv_in,1);
27 CHECK_INPUT(nv_out,1);
28
29 // get the dims required by computations
30 int Np = xyz_in.size(0);
31 int B = nv_in.size(0);
32
33 TORCH_CHECK(xyz_in.dim()==2 && xyz_in.size(1)==3, "FarthestPointSample expects (Np,3) inp shape");
34
35 const float* xyzIn_ptr = xyz_in.data_ptr<float>();
36 const int* nvIn_ptr = nv_in.data_ptr<int32_t>();
37 const int* nvOut_ptr = nv_out.data_ptr<int32_t>();
38
39 int Mp = computeOutputSize(B, nvOut_ptr); // extract Mp from nvOut
40
41 auto temp = torch::zeros({Np}, xyz_in.options());
42 auto index_out = torch::zeros({Mp}, xyz_in.options().dtype(torch::kInt32));
43 float* temp_ptr = temp.data_ptr<float>();
44 int* indexOut_ptr = index_out.data_ptr<int32_t>();
45
46 farthestPointSampleLauncher(B, Np, nvIn_ptr, nvOut_ptr, xyzIn_ptr, temp_ptr, indexOut_ptr);
47 return index_out;
48}
49
50
51PYBIND11_MODULE(TORCH_EXTENSION_NAME, m)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected