-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample.py
More file actions
48 lines (25 loc) · 712 Bytes
/
example.py
File metadata and controls
48 lines (25 loc) · 712 Bytes
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
'''
python wrapper for knncuda
Author: Dylan (Wenxuan) Wu
Date: 08/2019
'''
import numpy as np
import knn_util
import time
ref_num = 16384
query_num = 4096
dim = 3
k = 16
ref_data = np.random.rand(ref_num, dim)
query_data = np.random.rand(query_num, dim)
num_iter = 100
start_t = time.time()
for i in range(num_iter):
# note the input array should be contiguous and dim x num, and the output is num x k
dist, inds = knn_util.KNN(ref_data, query_data, k)
total_time = time.time() - start_t
print("ref_num : ", ref_num)
print("query_num : ", query_num)
print("dim : ", dim)
print("num of neighbours : ", k)
print("mean time over {} iter : ".format(num_iter), total_time / num_iter)