coremltools
coremltools copied to clipboard
pytorch inverse op implementation
❓Question
Hello, when i'm trying to convert pytorch model which uses torch.inverse(), i get the following error: 'RuntimeError: PyTorch convert function for op 'inverse' not implemented.'
OS: Ubuntu 18.04.4 LTS coremltools version: 4.0b4
Any chances that it will be implemented soon?
Actually i've made a stop-gap solution for 2x2 matriсes, but this is really a dirty hack : )
def inverter(t):
res = t.clone()
tmp = t[:,:,0,0]*t[:,:,1,1]-t[:,:,0,1]*t[:,:,1,0]
tmp = tmp.view(-1,1,1)
tmp = torch.div(t,tmp)
res[:,:,0,0] = tmp[:,:,1,1]
res[:,:,1,1] = tmp[:,:,0,0]
res[:,:,0,1] = -tmp[:,:,0,1]
res[:,:,1,0] = -tmp[:,:,1,0]
return res
Does coremltools support torch.inverse now?
Does coremltools support torch.inverse now?
Coremltools does not support this PyTorch op. I don't think there is any reasonable way to compute the inverse of a matrix using the current MIL ops; I think this will require a new MIL op which would be a change in the Core ML Framework.
Please submit this feature request for the Core ML Framework using the Feedback Assistant.