torch_npu.contrib.npu_giou
API接口
torch_npu.contrib.npu_giou(boxes1,boxes2,is_permuted=True)
参数说明
- boxes1 (Tensor) - 格式为xywh、shape为(4, n)的预测检测框。
- boxes2 (Tensor) - 相应的gt检测框,shape为(4, n)。
- is_permuted(bool) - 坐标值是否已经标准化。默认为True。
约束说明
仅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()
父主题: torch_npu.contrib