Tencent / ncnn

ncnn is a high-performance neural network inference framework optimized for the mobile platform
Other
20.33k stars 4.15k forks source link

pnnx Unknown builtin op: torchvision::nms. #4897

Open lizheng1992 opened 1 year ago

lizheng1992 commented 1 year ago

error log | 日志或报错信息 | ログ

base) ➜ bin git:(master) ./pnnx end2end.pt pnnxparam = end2end.pnnx.param pnnxbin = end2end.pnnx.bin pnnxpy = end2end_pnnx.py pnnxonnx = end2end.pnnx.onnx ncnnparam = end2end.ncnn.param ncnnbin = end2end.ncnn.bin ncnnpy = end2end_ncnn.py fp16 = 1 optlevel = 2 device = cpu inputshape = inputshape2 = customop = moduleop = terminate called after throwing an instance of 'torch::jit::ErrorReport' what():
Unknown builtin op: torchvision::nms. Could not find any similar ops to torchvision::nms. This op may not exist or may not be currently supported in TorchScript. : File "code/torch/torchvision/ops/boxes.py", line 24 _6 = torch.torchvision.extension._assert_has_ops _7 = _6() _8 = ops.torchvision.nms(boxes, scores, iou_threshold)


  return _8
'nms' is being compiled since it was called from '_batched_nms_coordinate_trick'
  File "/environment/miniconda3/lib/python3.7/site-packages/torchvision/ops/boxes.py", line 87
    offsets = idxs.to(boxes) * (max_coordinate + torch.tensor(1).to(boxes))
    boxes_for_nms = boxes + offsets[:, None]
    keep = nms(boxes_for_nms, scores, iou_threshold)
           ~~~ <--- HERE
    return keep
Serialized   File "code/__torch__/torchvision/ops/boxes.py", line 16
    _5 = torch.unsqueeze(torch.slice(offsets), 1)
    boxes_for_nms = torch.add(boxes, _5)
    keep = __torch__.torchvision.ops.boxes.nms(boxes_for_nms, scores, iou_threshold, )
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    _0 = keep
  return _0
'_batched_nms_coordinate_trick' is being compiled since it was called from 'RTMDet.forward'
Serialized   File "code/__torch__/mmdet/models/detectors/rtmdet.py", line 12
  def forward(self: __torch__.mmdet.models.detectors.rtmdet.RTMDet,
    batch_inputs: Tensor) -> Tuple[Tensor, Tensor]:
    _0 = __torch__.torchvision.ops.boxes._batched_nms_coordinate_trick
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ <--- HERE
    bbox_head = self.bbox_head
    neck = self.neck

[4]    72559 abort (core dumped)  ./pnnx end2end.pt
## context | 编译/运行环境 | バックグラウンド
-- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter Development Development.Module Development.Embed 
-- Using cached Torch install dir = /home/featurize/work/libtorch
-- Torch_VERSION = 2.0.1
-- Torch_VERSION_MAJOR = 2
-- Torch_VERSION_MINOR = 0
-- Torch_VERSION_PATCH = 1
CMake Warning at CMakeLists.txt:62 (message):
  Building without TorchVision

-- Building with onnx-zero
-- Found Python3: /usr/bin/python3.8 (found version "3.8.10") found components: Interpreter 
-- Configuring done
-- Generating done
## how to reproduce | 复现步骤 | 再現方法
1.
2.
3.

## more | 其他 | その他
nihui commented 2 months ago

针对onnx模型转换的各种问题,推荐使用最新的pnnx工具转换到ncnn In view of various problems in onnx model conversion, it is recommended to use the latest pnnx tool to convert your model to ncnn

pip install pnnx
pnnx model.onnx inputshape=[1,3,224,224]

详细参考文档 Detailed reference documentation https://github.com/pnnx/pnnx https://github.com/Tencent/ncnn/wiki/use-ncnn-with-pytorch-or-onnx#how-to-use-pnnx