以下是用 torch.ops.script_ops.while_loop 改造后的代码:
import torch
def py_cpu_nms2(dets, thresh):
x1 = dets[:, 0]
y1 = dets[:, 1]
x2 = dets[:, 2]
y2 = dets[:, 3]
scores = dets[:, 4]
areas = (x2 - x1 + 1) * (y2 - y1 + 1)
order = scores.argsort(descending=True)
d