NNAPI Serializer: dealing with unsupported operation transpose

Hi,

I am trying to convert a model (namely shufflenet) for android using NNAPI but am running into some issues related to unsupported operations - namely transpose and contiguous.

How can I change my model so that it will convert?

class ChannelShuffle(nn.Module):
    def __init__(self, groups):
        super().__init__()
        self.groups = groups
    
    def forward(self, x):
        N,C,H,W = x.size() 
        g = self.groups
        x = x.reshape(N, g, -1, H, W)
        x = torch.transpose(x, 1, 2).contiguous() # this is the offending line
        x = x.reshape(N,C,H,W)
        
        return x

Thank you,
Jeeheh

Hi Jeeheh, at this time we don’t support transpose in NNAPI: https://github.com/pytorch/pytorch/blob/master/torch/backends/_nnapi/serializer.py#L784

We’re open to contributions to add more op support