该接口计划废弃,可以使用torch_npu.npu_giou接口进行替换。
torch_npu.contrib.npu_giou(boxes1,boxes2,is_permuted=True)
提供NPU版本的GIoU计算接口。
仅trans=True(仅支持xywh,不支持xyxy), is_cross=False(仅支持boxes1.shape ==boxes2.shape,不支持((n,4), (m,4)))。
>>> box1 = torch.randn(32, 4) >>> box1.requires_grad = True >>> box2 = torch.randn(32, 4) >>> iou1 = npu_giou(box1, box2) # (32, 1) >>> l = iou1.sum() >>> l.backward()