-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
[Feature] Add gather points op from mmdet3d #1338
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1338 +/- ##
==========================================
- Coverage 68.59% 68.51% -0.09%
==========================================
Files 164 165 +1
Lines 10891 10922 +31
Branches 1991 1993 +2
==========================================
+ Hits 7471 7483 +12
- Misses 3030 3047 +17
- Partials 390 392 +2
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Hi, I think this ops can be implemented with PyTorch only: # method0, permute might take extra computation
def gather_point_pytorch0(features, idx):
batch_size = features.shape[0]
batch_idx = torch.arange(batch_size, device=features.device).unsqueeze(-1)
permute_output = features[batch_idx, :, idx]
return permute_output.permute(0, 2, 1)
# method1, repeat might need more memory
def gather_point_pytorch1(features, idx):
new_idx = idx.unsqueeze(1).repeat(1, 3, 1)
return features.gather(2, new_idx) |
We tested that the running time of the PyTorch version code is 17.3 times that of the Cuda version code, so it is necessary to implement with cuda. |
Here is my timer: def timer(func, num_test, num_warmup, *args, **kwargs):
start = torch.cuda.Event(enable_timing=True)
end = torch.cuda.Event(enable_timing=True)
# warmup
for _ in range(num_warmup):
func(*args, **kwargs)
torch.cuda.synchronize()
start.record()
for _ in range(num_test):
output = func(*args, **kwargs)
end.record()
torch.cuda.synchronize()
print(f'{func} take time {start.elapsed_time(end)/num_test}.')
return output With |
Need to resolve conflict and clean DIVUP before merge. |
Motivation
Add gather points cuda operation from mmdet3d (branch: v1.0.0.dev0).
Modification
Several files in mmcv/ops folder.
BC-breaking (Optional)
No.
Use cases (Optional)
from mmcv.ops import gather_points