MCPcopy Create free account
hub / github.com/pytorch/executorch / lower_module_to_coreml

Function lower_module_to_coreml

examples/apple/coreml/scripts/export.py:107–125  ·  view source on GitHub ↗
(module, compile_specs, example_inputs)

Source from the content-addressed store, hash-verified

105
106
107def lower_module_to_coreml(module, compile_specs, example_inputs):
108 module = module.eval()
109 edge = to_edge(
110 torch.export.export(module, example_inputs, strict=True),
111 compile_config=_EDGE_COMPILE_CONFIG,
112 )
113 # All of the subsequent calls on the edge_dialect_graph generated above (such as delegation or
114 # to_executorch()) are done in place and the graph is also modified in place. For debugging purposes
115 # we would like to keep a copy of the original edge dialect graph and hence we create a deepcopy of
116 # it here that will later then be serialized into a etrecord.
117 edge_copy = copy.deepcopy(edge)
118
119 lowered_module = to_backend(
120 CoreMLBackend.__name__,
121 edge.exported_program(),
122 compile_specs,
123 )
124
125 return lowered_module, edge_copy
126
127
128def export_lowered_module_to_executorch_program(lowered_module, example_inputs):

Callers 1

mainFunction · 0.85

Calls 4

to_edgeFunction · 0.90
to_backendFunction · 0.90
exportMethod · 0.45
exported_programMethod · 0.45

Tested by

no test coverage detected