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

points_in_boxes_all和points_in_boxes_part的mmcv兼容npu判断 #3189

Open
wants to merge 2 commits into
base: main
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
12 changes: 8 additions & 4 deletions mmcv/ops/points_in_boxes.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,11 @@ def points_in_boxes_part(points: Tensor, boxes: Tensor) -> Tensor:
points_device = points.get_device()
assert points_device == boxes.get_device(), \
'Points and boxes should be put on the same device'
if torch.cuda.current_device() != points_device:
torch.cuda.set_device(points_device)
if points.device.type != 'npu':
if torch.cuda.current_device() != points_device:
torch.cuda.set_device(points_device)
else:
boxes[:, :, 2] += boxes[:, :, 5] / 2.0

ext_module.points_in_boxes_part_forward(boxes.contiguous(),
points.contiguous(),
Expand Down Expand Up @@ -127,8 +130,9 @@ def points_in_boxes_all(points: Tensor, boxes: Tensor) -> Tensor:
points_device = points.get_device()
assert points_device == boxes.get_device(), \
'Points and boxes should be put on the same device'
if torch.cuda.current_device() != points_device:
torch.cuda.set_device(points_device)
if points.device.type != 'npu':
if torch.cuda.current_device() != points_device:
torch.cuda.set_device(points_device)

ext_module.points_in_boxes_all_forward(boxes.contiguous(),
points.contiguous(),
Expand Down
Loading