Problems with the combination of torch.jit.trace and torch.complie

import torch
from torchvision import models

net = models.resnet18(pretrained=True)
cnet = torch.compile(net)
data = torch.randn(1, 3, 224, 224)
tnet = torch.jit.trace(cnet, data)
ERROR:Graphs differed across invocations!

Is this normal?Why?

I don’t think tracing a compiled model is supported and you should use torch.compile only in recent PyTorch releases.

1 Like

Yeah torch.compile() and torch.jit() do not compose, if you’re looking for serialization I’d suggest you take a look at torch.export.export() instead

1 Like

Can a torch.export.export() saved model be loaded on the C++ side now?