-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathwrapper.pyx
39 lines (29 loc) · 1.65 KB
/
wrapper.pyx
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
import numpy as np
import cython
cimport numpy as np
assert sizeof(int) == sizeof(np.int32_t)
cdef extern from "src/manager.hh":
cdef cppclass C_GPUTransformer "GPUTransformer":
C_GPUTransformer(float *point, int size, int *x, int *y, int *height, int max_length, int max_height, int num_x, int num_y, int num_height, int enough_large)
void transform()
void retreive(float *point_trans)
cdef class GPUTransformer:
cdef C_GPUTransformer* g
cdef int size
cdef int grid_size
def __cinit__(self, np.ndarray[float, ndim=1, mode = "c"] point not None,
int size, int max_length, int max_height, int num_x, int num_y, int num_height, int enough_large):
self.size = size
self.grid_size = num_x * num_y * num_height * enough_large
cdef np.ndarray[int, ndim=1, mode = "c"] y = np.zeros(self.size, dtype=np.int32)
cdef np.ndarray[int, ndim=1, mode = "c"] x = np.zeros(self.size, dtype=np.int32)
cdef np.ndarray[int, ndim=1, mode = "c"] height = np.zeros(self.size, dtype=np.int32)
self.g = new C_GPUTransformer(&point[0], self.size, &x[0], &y[0], &height[0], max_length, max_height, num_x, num_y, num_height, enough_large)
def transform(self):
self.g.transform()
def retreive(self):
cdef np.ndarray[int, ndim=1, mode = "c"] grid_out = np.zeros(self.size, dtype=np.int32)
cdef np.ndarray[int, ndim=1, mode = "c"] mask_out = np.zeros(self.size, dtype=np.int32)
cdef np.ndarray[float, ndim=1, mode = "c"] point_out = np.zeros(self.grid_size * 3, dtype=np.float32)
self.g.retreive(&point_out[0])
return point_out