import torchfrom torch.export import exportfrom executorch.exir import to_edge# Start with a PyTorch model that adds two input tensors (matrices)classAdd(torch.nn.Module):def__init__(self):super(Add, self).__init__()defforward(self,x: torch.Tensor,y: torch.Tensor):return x + y# 1. torch.export: Defines the program with the ATen operator set.aten_dialect =export(Add(), (torch.ones(1), torch.ones(1)))# 2. to_edge: Make optimizations for Edge devicesedge_program =to_edge(aten_dialect)# 3. to_executorch: Convert the graph to an ExecuTorch programexecutorch_program = edge_program.to_executorch()# 4. Save the compiled .pte programwithopen("add.pte", "wb")as file: file.write(executorch_program.buffer)