I’m registering custom ops from TorchScript to ONNX refer to https://pytorch.org/docs/stable/onnx.html#custom-operators, But I met the following error:
Traceback (most recent call last):
File "onnx_demo.py", line 23, in <module>
print(torch.ops.custom_ops.intersection)
File "/home/dai/py36env/lib/python3.6/site-packages/torch/_ops.py", line 61, in __getattr__
op = torch._C._jit_get_operation(qualified_op_name)
RuntimeError: No such operator custom_ops::intersection
Here is my code:
torch.ops.load_library("build/libexample.so")
def intersection(g,p):
return torch.ops.my_ops.iou(g[:8],p[:8])
print(torch.ops.my_ops.iou)
register_custom_op_symbolic('custom_ops::intersection', intersection, 11)
# register_custom_op_symbolic('custom_ops::intersection', torch.ops.my_ops.iou, 11)
print(torch.ops.custom_ops.intersection)
libexample.so is the custom op file of TorchScript defined in C++. How can I convert it to ONNX op?