Using torch.compile - 57300

ZenDNN User Guide (57300)

Document ID
57300
Release Date
2025-08-18
Revision
5.1 English

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)