(module, compile_specs, example_inputs)
| 105 | |
| 106 | |
| 107 | def 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 | |
| 128 | def export_lowered_module_to_executorch_program(lowered_module, example_inputs): |
no test coverage detected