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

Move copy method to improve efficiency in RandLANet's transform method #655

Open
3 tasks done
gaetanochiriaco opened this issue Sep 3, 2024 · 0 comments
Open
3 tasks done

Comments

@gaetanochiriaco
Copy link

Checklist

Proposed new feature or change

Current Behavior

The transform method of the RandLANet class is currently creating copies of the input data before sampling points. This significantly impacts performance, especially when dealing with large pointcloud files containing millions of points.

pc = data['point'].copy()
label = data['label'].copy()
feat = data['feat'].copy() if data['feat'] is not None else None
tree = data['search_tree']
pc, selected_idxs, center_point = self.trans_point_sampler(
pc=pc,
feat=feat,
label=label,
search_tree=tree,
num_points=self.cfg.num_points)
label = label[selected_idxs]
if feat is not None:
feat = feat[selected_idxs]

random.shuffle(idxs)
pc = pc[idxs]
return pc, idxs, center_point

Proposed Change

Move the copy() operations to after the point sampling. The point sampler doesn't perform any in-place operations on the pc array, so it shouldn't have any side effects on the original pointcloud.

pc = data["point"]  # full pointcloud (N,3)
label = data["label"]
feat = data["feat"] if data["feat"] is not None else None
tree = data["search_tree"]

selected_idxs, center_point = self.trans_point_sampler(
    pc=pc,
    feat=feat,
    label=label,
    search_tree=tree,
    num_points=self.cfg.num_points,
    sampler=self.cfg.get("sampler", None),
)  # Points are sampled from the whole pointcloud (n_points,3)
pc_sub = pc[selected_idxs]
pc = pc_sub.copy()
label_sub = label[selected_idxs]
label = label_sub.copy()
if feat is not None:
    feat_sub = feat[selected_idxs]
    feat = feat_sub.copy()
random.shuffle(idxs)
return idxs, center_point

References

No response

Additional information

Performance Improvement

I have run performance tests on both the current and proposed implementations, running a single epoch with this configuration ml3d/configs/randlanet_toronto3d.yml .
test_copy
test_nocopy

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant