xref: /aosp_15_r20/external/pytorch/ios/TestApp/custom_build/custom_build.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1import yaml
2from torchvision import models
3
4import torch
5
6
7model = models.mobilenet_v2(weights=models.MobileNet_V2_Weights.IMAGENET1K_V1)
8model.eval()
9example = torch.rand(1, 3, 224, 224)
10traced_script_module = torch.jit.trace(model, example)
11ops = torch.jit.export_opnames(traced_script_module)
12with open("mobilenetv2.yaml", "w") as output:
13    yaml.dump(ops, output)
14