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