Understand export and lowering

The central export and lowering sequence is:

    

        
        
example_inputs = (torch.randn(*spec["input"]["shape"]),)

with torch.inference_mode():
    exported = export(model, example_inputs)

edge = to_edge_transform_and_lower(
    exported,
    partitioner=[XnnpackPartitioner()],
)
program = edge.to_executorch()

    
ExecuTorch API Highlight

This is the same ExecuTorch lowering API used in Module 1. to_edge_transform_and_lower() creates the edge program, XnnpackPartitioner() selects supported regions for CPU delegation, and to_executorch() creates the deployable program.

This is the same export-and-lower sequence used for GPT-2 and DistilBERT in Module 1. The difference lies in the graph. Transformer graphs contain attention, masks, reshapes, indexing, and normalization around their main compute. MobileNetV2 is dominated by convolution patterns that can form a more compact XNNPACK region.

Previous page Complete and continue