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

Function to_edge_transform_and_lower

exir/program/_program.py:1324–1447  ·  view source on GitHub ↗

:func:`to_edge_transform_and_lower` constructs an EdgeProgramManager from a set of exported programs in ATen dialect. It differs fundamentally from to_edge in that it combines the conversion of the ATen dialect to the edge dialect program, then running the transformation passes and

(  # noqa: C901
    programs: Union[ExportedProgram, Dict[str, ExportedProgram]],
    transform_passes: Optional[
        Union[Sequence[PassType], Dict[str, Sequence[PassType]], PassManager]
    ] = None,
    partitioner: Optional[
        Union[List[Partitioner], Dict[str, List[Partitioner]]]
    ] = None,
    constant_methods: Optional[Dict[str, Any]] = None,
    compile_config: Optional[EdgeCompileConfig] = None,
    generate_etrecord: bool = False,
)

Source from the content-addressed store, hash-verified

1322
1323@et_logger("to_edge_transform_and_lower")
1324def to_edge_transform_and_lower( # noqa: C901
1325 programs: Union[ExportedProgram, Dict[str, ExportedProgram]],
1326 transform_passes: Optional[
1327 Union[Sequence[PassType], Dict[str, Sequence[PassType]], PassManager]
1328 ] = None,
1329 partitioner: Optional[
1330 Union[List[Partitioner], Dict[str, List[Partitioner]]]
1331 ] = None,
1332 constant_methods: Optional[Dict[str, Any]] = None,
1333 compile_config: Optional[EdgeCompileConfig] = None,
1334 generate_etrecord: bool = False,
1335) -> "EdgeProgramManager":
1336 """
1337 :func:`to_edge_transform_and_lower` constructs an EdgeProgramManager from a set of
1338 exported programs in ATen dialect. It differs fundamentally from to_edge in that it
1339 combines the conversion of the ATen dialect to the edge dialect program, then running
1340 the transformation passes and then subsequently lowering the programs to their
1341 corresponding backends all into a single API.
1342
1343 This is fundamentally useful for lowering to backends that have ops registered that they
1344 do not want to be decomposed and thus rely on matching with these non-decomposed ops. For
1345 these sorts of backends this is the *only* API that should be used to lower to the edge
1346 dialect. Using a combination of to_edge(...) and to_backend(...) will result in inconsistent
1347 or wrong behavior.
1348
1349 This API is the primary recommended way to lower to the CPU based XNNPack backend.
1350
1351 Args:
1352 programs: Can be a single ExportedProgram or a dictionary mapping function names
1353 to their corresponding ExportedPrograms. If only a single ExportedProgram is
1354 provided it will be assigned the name "forward".
1355
1356 transform_passes: The transform_passes can be one of:
1357 1) a list of passes -
1358 all methods in the given EdgeProgramManager will be transformed with the provided passes.
1359 2) a dictionary -
1360 only method names specified in the dictionary will be transformed
1361 with their corresponding passes
1362 3) an instance of a PassManager -
1363 all methods in the given EdgeProgramManager will be
1364 transformed with the given PassManager instance.
1365
1366 partitioner: The partitioner can either be a Partitioner subclass instance, or a
1367 dictionary mapping method names to Partitioner subclass instance. If it is a
1368 Partitioner subclass, all programs in the given EdgeProgramManager will be lowered
1369 using the given partitioner. If it is a dictionary, only method names specified in
1370 the dictionary will be lowered with the given partitioner.
1371
1372 constant_methods: An optional dictionary of method name to the constant value
1373 returned by that method in eager mode. Often used to store config information on
1374 Edge models.
1375
1376 compile_config: An optional argument used to provide greater control over the
1377 transformation to edge dialect process.
1378
1379 generate_etrecord: An optional argument used to generate an etrecord for debugging purposes.
1380
1381 Returns:

Calls 15

EdgeCompileConfigClass · 0.90
EXIREdgeDialectVerifierFunction · 0.90
keysMethod · 0.80
valuesMethod · 0.80
itemsMethod · 0.80
unionMethod · 0.80
transformMethod · 0.45