33# Copyright (C) 2023-now, RPL, KTH Royal Institute of Technology
44# Author: Qingwen Zhang (https://kin-zhang.github.io/)
55#
6- # This work is licensed under the terms of the MIT license.
7- # For a copy, see <https://opensource.org/licenses/MIT>.
8-
6+ #
97# Description: Test which existing chamfer distance is faster.
108
11- Dependence:
9+ Dependence for this test scripts :
1210 * faiss-gpu
1311 * Pytorch3d
1412 * mmcv
2927CUDA_TEST = True
3028
3129if __name__ == "__main__" :
32- pc0 = np .load (' test_pc0.npy' )
33- pc1 = np .load (' test_pc1.npy' )
30+ pc0 = np .load (f' { BASEF_DIR } /assets/tests/ test_pc0.npy' )
31+ pc1 = np .load (f' { BASEF_DIR } /assets/tests/ test_pc1.npy' )
3432 print ('Start status on GPU allocation: {:.3f}MB' .format (torch .cuda .memory_allocated ()/ 1024 ** 2 ))
3533 pc0 = torch .from_numpy (pc0 [...,:3 ]).float ().cuda ().contiguous ()
3634 pc1 = torch .from_numpy (pc1 [...,:3 ]).float ().cuda ().contiguous ()
@@ -101,8 +99,8 @@ def faiss_knn(pc1, pc2):
10199 from assets .cuda .chamfer3D import nnChamferDis
102100 start_time = time .time ()
103101 loss = nnChamferDis (truncate_dist = False )(pc0 , pc1 )
104- print (f"Chamfer Distance Cal time: { (time .time () - start_time )* 1000 :.3f} ms" )
105102 print ("loss: " , loss )
103+ print (f"Chamfer Distance Cal time: { (time .time () - start_time )* 1000 :.3f} ms" )
106104 print ()
107105
108106"""
@@ -124,7 +122,7 @@ def faiss_knn(pc1, pc2):
124122mmcv Chamfer Distance Cal time: 651.510 ms
125123
126124------ START CUDA Chamfer Distance Cal ------
127- Chamfer Distance Cal time: 1.667 ms
125+ Chamfer Distance Cal time: 14.308 ms
128126loss: tensor(0.1710, device='cuda:0', grad_fn=<AddBackward0>)
129127
130128"""
0 commit comments