"test/srt/openai_server/basic/test_serving_embedding.py" did not exist on "09ae5b20f3123487f36097d284a1f535cd267e7b"
ball_query.cpp 1.52 KB
Newer Older
wuyuefeng's avatar
wuyuefeng committed
1
2
3
4
#include <THC/THC.h>
#include <cuda.h>
#include <cuda_runtime_api.h>
#include <torch/extension.h>
zhangwenwei's avatar
zhangwenwei committed
5
6
7
#include <torch/serialize/tensor.h>

#include <vector>
wuyuefeng's avatar
wuyuefeng committed
8
9
10

extern THCState *state;

zhangwenwei's avatar
zhangwenwei committed
11
12
13
14
15
16
17
#define CHECK_CUDA(x) \
  TORCH_CHECK(x.type().is_cuda(), #x, " must be a CUDAtensor ")
#define CHECK_CONTIGUOUS(x) \
  TORCH_CHECK(x.is_contiguous(), #x, " must be contiguous ")
#define CHECK_INPUT(x) \
  CHECK_CUDA(x);       \
  CHECK_CONTIGUOUS(x)
wuyuefeng's avatar
wuyuefeng committed
18
19

int ball_query_wrapper(int b, int n, int m, float radius, int nsample,
zhangwenwei's avatar
zhangwenwei committed
20
21
                       at::Tensor new_xyz_tensor, at::Tensor xyz_tensor,
                       at::Tensor idx_tensor);
wuyuefeng's avatar
wuyuefeng committed
22
23

void ball_query_kernel_launcher(int b, int n, int m, float radius, int nsample,
zhangwenwei's avatar
zhangwenwei committed
24
25
                                const float *xyz, const float *new_xyz,
                                int *idx, cudaStream_t stream);
wuyuefeng's avatar
wuyuefeng committed
26
27

int ball_query_wrapper(int b, int n, int m, float radius, int nsample,
zhangwenwei's avatar
zhangwenwei committed
28
29
30
31
32
33
34
35
                       at::Tensor new_xyz_tensor, at::Tensor xyz_tensor,
                       at::Tensor idx_tensor) {
  CHECK_INPUT(new_xyz_tensor);
  CHECK_INPUT(xyz_tensor);
  const float *new_xyz = new_xyz_tensor.data_ptr<float>();
  const float *xyz = xyz_tensor.data_ptr<float>();
  int *idx = idx_tensor.data_ptr<int>();

36
  cudaStream_t stream = at::cuda::getCurrentCUDAStream().stream();
zhangwenwei's avatar
zhangwenwei committed
37
38
39
  ball_query_kernel_launcher(b, n, m, radius, nsample, new_xyz, xyz, idx,
                             stream);
  return 1;
wuyuefeng's avatar
wuyuefeng committed
40
41
42
}

PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
zhangwenwei's avatar
zhangwenwei committed
43
  m.def("ball_query_wrapper", &ball_query_wrapper, "ball_query_wrapper");
wuyuefeng's avatar
wuyuefeng committed
44
}