torch.onnx.errors.UnsupportedOperatorError: Exporting the operator 'aten::randperm' to ONNX opset version 15 is not supported


I am trying to use Pytorch FasterRCNN model with ORTModule. However I get the following error when trying to wrap my model:

[torch.onnx.errors.UnsupportedOperatorError: Exporting the operator ‘aten::randperm’ to ONNX opset version 15 is not supported]

I tried adding the function myself with the following code:

def aten_randperm(g, self, *args):
output=g.op(“aten::randperm”, self, *args)
return output

I registered this operation by using:

register_custom_op_symbolic(‘::randperm’, symbolic_opset14.aten_randperm, 14)

The error dissapeared and then a similar error related to aten::smooth_l1_loss arised. I did similar procedure to add it and moved forward.

Now I am getting the following error: There was an error while exporting the PyTorch model to ONNX:
File “/home/op/anaconda3/envs/py310ort/lib/python3.10/site-packages/torch/onnx/”, line 2244, in _or raise errors.SymbolicValueError( torch.onnx.errors.SymbolicValueError: ONNX export does NOT support exporting bitwise OR for non-boolean input values [Caused by the value ‘4292 defined in (%4292 : Byte(*, strides=[1], requires_grad=0, device=cuda:0) = onnx::ScatterND(%4273, %4277, %4291), scope: # [/home/op/anaconda3/envs/py310ort/lib/python3.10/site-packages/torchvision/models/detection/]’ (type ‘Tensor’) in the TorchScript graph. The containing node has kind ‘onnx::ScatterND’.] (node defined in /home/op/anaconda3/envs/py310ort/lib/python3.10/site-packages/torchvision/models/detection/ call

Currently I have not being able to work with any of the object detection models (FasterRCNN, Fcos) or Deeplab for Semantic Segmentation inside the ORTModule.

Could you please help me figure out what could possibly be causing this problem? Is it maybe my implementation for the custom operators?

I am currently using Pyhon 3.10, onnx 1.14.1, torch_ort 1.15.0 and Pytorch 2.0.1+cu117