In most cases, you can simply set backend='zentorch'
as an argument in torch.compile() to enable
optimizations. Additionally, for Hugging Face large language models, we provide
zentorch.llm.optimize(), a specialized method
that delivers further performance enhancements. For additional guidance on usage
scenarios, refer to the Recommendations
section.
import torch
import zentorch
from torchvision import models
model = models.__dict__['resnet50'](pretrained=True).eval()
compiled_model = torch.compile(model, backend='zentorch', dynamic = False)
with torch.no_grad():
output = compiled_model(input)