The following operators are not implemented: ['aten::triu', 'prim::PythonOp', 'aten::copy_']

I’m using relay.frontend.from_pytorch to convert pytorch model, but face some problem on this: File “TSM_tvm.py”, line 52, in torch2tvm_module relay_module, params = tvm.relay.frontend.from_pytorch(scripted_model, shape_list) File “/home/po/Desktop/tvm/python/tvm/relay/frontend/pytorch.py”, line 3996, in from_pytorch converter.report_missing_conversion(op_names) File “/home/po/Desktop/tvm/python/tvm/relay/frontend/pytorch.py”, line 3202, in report_missing_conversion raise NotImplementedError(msg) NotImplementedError: The following operators are not implemented: [‘aten::triu’, ‘prim::PythonOp’, ‘aten::copy_’]

python v3.8, pytorch v1.7.0, TVM v0.9

Can anyone help me? Thanks

aten::triu can be supported, but prim::PythonOp is impossible to support. You need to remove a custom PyTorch op rewritten in python from your model.

And we are not supporting aten::copy_, since Relay does not support in-place copy semantics.

I’ve found sometimes that exporting the model to ONNX first, and importing the ONNX model into TVM can side-step this issue. At least, this helped for me with StyleGAN2-ADA.

However if the ops are not supported by ONNX then TVM will also have an issue.

Sometimes model writers for PyTorch will create custom C++/CUDA versions of their ops to speed up training, which are represented as prim::PythonOp when attempting to import into TVM. However sometimes there may also be a “pure PyTorch” implementation of said operations that can be enabled.