[C++] [TorchScript] torchvision::nms not in TorchScript

Hello, this topic is relevant to ([Torchvision] [Android] Torchvision.ops when will they be available on Mobile)

I’ve tried to load a model exported using torchscript with C++ API (https://download.pytorch.org/libtorch/nightly/cpu/libtorch-cxx11-abi-shared-with-deps-latest.zip) and it produces errors the same as JNI does

root@Callisto:~/libtorch_examples/build# ./example-app /root/libtorch_examples/scripted_rpn.pt 
terminate called after throwing an instance of 'torch::jit::script::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.
:
Serialized at code/__torch__/torchvision/ops/boxes.py:25:7
    scores: Tensor,
    iou_threshold: Tensor) -> Tensor:
  _7 = ops.torchvision.nms(boxes, scores, annotate(float, iou_threshold))
       ~~~~~~~~~~~~~~~~~~~ <--- HERE

How to make this operation available from C++?

1 Like

Hi, I meet same problem as you. Do you find the way to solve it out? Thx~

I’ve implemented slow python analogue of C++ operation and it’s worked well