Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

three_nn gpu implementation. #96

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion utils/pointnet_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,17 @@ def pointnet_sa_module_msg(xyz, points, npoint, radius_list, nsample_list, mlp_l
new_points_concat = tf.concat(new_points_list, axis=-1)
return new_xyz, new_points_concat

def three_nn_gpu(xyz1, xyz2):
s1=tf.shape(xyz1)
s2=tf.shape(xyz2)
xyz1=tf.reshape(xyz1, (s1[0],s1[1],1,-1))
xyz2=tf.reshape(xyz2, (s2[0],1,s2[1],-1))
dist=xyz2-xyz1
dist=dist*dist
dist=tf.reduce_sum(dist,-1)
if dist.shape[-1]==1:
dist=tf.tile(dist,(1,1,3))
return tf.nn.top_k(-dist, k=3)

def pointnet_fp_module(xyz1, xyz2, points1, points2, mlp, is_training, bn_decay, scope, bn=True):
''' PointNet Feature Propogation (FP) Module
Expand All @@ -208,7 +219,7 @@ def pointnet_fp_module(xyz1, xyz2, points1, points2, mlp, is_training, bn_decay,
new_points: (batch_size, ndataset1, mlp[-1]) TF tensor
'''
with tf.variable_scope(scope) as sc:
dist, idx = three_nn(xyz1, xyz2)
dist, idx = three_nn_gpu(xyz1, xyz2)
dist = tf.maximum(dist, 1e-10)
norm = tf.reduce_sum((1.0/dist),axis=2,keep_dims=True)
norm = tf.tile(norm,[1,1,3])
Expand Down