Torch.onnx.export() - No ONNX function for OpOverload

MSK28: <p>Hi there!<br>
I am by far not the most experienced PyTorch User and some errors have occurred lately.<br>
I want to export a model with some custom implementations using torch.onnx.export().<br>
I use functions such as torch.linalg.pinv() for the Pseudo Inverse and others.</p>
<p>When trying to export the model, I get error messages. I have been able to identify the fact, that ONNX is yet to support some linear algebra operations such as pinv() that I use.<br>
The official PyTorch Doc has information about exactly that.<br>
<a href="https://pytorch.org/docs/stable/onnx_torchscript.html#example-alexnet-from-pytorch-to-onnx" rel="noopener nofollow ugc">https://pytorch.org/docs/stable/onnx_torchscript.html#example-alexnet-from-pytorch-to-onnx</a></p>
<p>I am not scared of implementing something myself and learning new stuff. Hence I implemented the missing code in the symbolic_opset20.py file as mentioned.<br>
But it did not change anything and the error is still present.</p>
<p>I guess the problem is actually not the operation missing but something that happens inside the operation or with my implementation?<br>
Because it does not tell me that the operation is missing but that some OpOverload fails / is missing.<br>
Would someone maybe have an idea on how to tackle this?<br>
I tried replacing the pseudo inverse command with SVD but that uses operations that are also not implemented.</p>
<p><strong>Error Message:</strong><br>
&lt;class ‘torch.onnx._internal.exporter._errors.DispatchError’&gt;: No ONNX function found for &lt;OpOverload(op=‘aten.linalg_pinv’, overload=‘atol_rtol_tensor’)&gt;. Failure message: No decompositions registered for the real-valued input<br>
<img src="https://discuss.pytorch.org/images/emoji/apple/arrow_up.png?v=12" title=":arrow_up:" class="emoji only-emoji" alt=":arrow_up:" loading="lazy" width="20" height="20"><br>
&lt;class ‘torch.onnx._internal.exporter._errors.ConversionError’&gt;: Error when translating node %linalg_pinv : [num_users=1] = call_function[target=torch.ops.aten.linalg_pinv.atol_rtol_tensor](args = (%stack,), kwargs = {}). See the stack trace for more information.</p>

take-cheeze: <p>Seems inverse operator hasn’t made it to onnx spec.<br>
Though there is some ops implemented in onnxruntime as contrib_ops:</p>
<ul>
<li><a href="https://github.com/microsoft/onnxruntime/pull/18621" class="inline-onebox" rel="noopener nofollow ugc">WIP Liqun/linalg by liqunfu · Pull Request #18621 · microsoft/onnxruntime · GitHub</a></li>
<li><a href="https://github.com/microsoft/onnxruntime/blob/545b77d82d17f8deff63c7dacd45ae1f4459b544/onnxruntime/python/tools/pytorch_export_contrib_ops.py#L70-L71" class="inline-onebox" rel="noopener nofollow ugc">onnxruntime/onnxruntime/python/tools/pytorch_export_contrib_ops.py at 545b77d82d17f8deff63c7dacd45ae1f4459b544 · microsoft/onnxruntime · GitHub</a></li>
</ul>

MSK28: <p>The matrix inverse wouldn’t be the problem i guess but pinverse is actually the pseudo inverse which is still a little bit different to it.<br>
I am pretty certain, that the error isn’t even yet the non-existing implementation of it but rather some other / deeper problem since it has some problem with the atl_rtol_tensor overload.<br>
However, if I pass atol and rtol as keyword arguments it still will throw errors and won’t work.</p>