• Docs >
  • Export to ExecuTorch API Reference
Shortcuts

Export to ExecuTorch API Reference

For detailed information on how APIs evolve and the deprecation process, please refer to the ExecuTorch API Life Cycle and Deprecation Policy.

executorch.exir.to_edge(self, *args, **kwargs)[source]
executorch.exir.to_edge_transform_and_lower(self, *args, **kwargs)[source]
class executorch.exir.EdgeProgramManager(edge_programs, constant_methods=None, compile_config=None, ops_set_to_not_decompose=None)[source]

Package of one or more ExportedPrograms in Edge dialect. Designed to simplify lowering to ExecuTorch. See: https://pytorch.org/executorch/stable/ir-exir.html

Allows easy applications of transforms across a collection of exported programs including the delegation of subgraphs.

Manages the second link in the lowering chain of ATen -> Edge -> ExecuTorch.

property config_methods

Returns the set of config methods in this EdgeProgramManager.

exported_program(method_name='forward')[source]

Returns the ExportedProgram specified by ‘method_name’.

property methods

Returns the set of methods in this EdgeProgramManager.

class executorch.exir.ExecutorchProgramManager(execution_programs, config_methods=None, backend_config=None)[source]

Package of one or more ExportedPrograms in Execution dialect. Designed to simplify lowering to ExecuTorch. See: https://pytorch.org/executorch/stable/ir-exir.html

When the ExecutorchProgramManager is constructed the ExportedPrograms in execution dialect are used to form the executorch binary (in a process called emission) and then serialized to a buffer.

Manages the final link in the lowering chain of ATen -> Edge -> ExecuTorch.

property buffer

Returns the serialized ExecuTorch binary as a byte string.

Note that the call to buffer may allocate a very large amount of contiguous memory, depending on the model size. If writing to a file, use write_to_file which won’t incur additional copies.

property config_methods

Returns the set of config methods in this ExecutorchProgramManager.

dump_executorch_program(verbose=False, out=None)[source]

Prints the ExecuTorch binary in a human readable format.

Parameters
  • verbose (bool) – If False prints the binary in a condensed format. If True prints the binary 1-1 with the specification in the schema.

  • out

    If None, prints to stdout. If non-None, writes the string to that stream object. It can be

    a file object, a StringIO object, or any other TextIO subclass.

exported_program(method_name='forward')[source]

Returns the ExportedProgram specified by ‘method_name’.

property methods

Returns the set of methods in this ExecutorchProgramManager.

executorch.exir.backend.backend_api.to_backend(args)[source]
executorch.exir.backend.backend_api.to_backend(backend_id, edge_program, compile_specs)
executorch.exir.backend.backend_api.to_backend(edge_program, partitioner_instance)

A generic function the dispatch happens on the type of the first argument. There are currently to overloaded to_backend function:

Note: Python is dynamically-typed language and therefore cannot have proper method overloading as that requires the language to be able to discriminate between types at compile-time. @to_backend.register will attach the function to to_backend() base on the type of the first argument (type annotation is required). However, it can’t take multiple types as arguments.

def to_backend(
    backend_id: str,
    edge_graph_module: ExportedProgram,
    compile_specs: List[CompileSpec],
) -> LoweredBackendModule:

def to_backend(
    graph_module: torch.fx.GraphModule,
    partitioner: Type[TPartitioner],
) -> torch.fx.GraphModule
class executorch.exir.backend.backend_api.LoweredBackendModule(edge_program, backend_id, processed_bytes, compile_specs)[source]

A subclass of nn.Module that is generated for modules containing delegated functions. This is can be created by calling to_backend.

property backend_id

Returns the backends name.

buffer(extract_delegate_segments=False, segment_alignment=128, constant_tensor_alignment=None, delegate_alignment=None, memory_planning=None)[source]

Returns a buffer containing the serialized ExecuTorch binary.

property compile_specs

Returns a list of backend-specific objects with static metadata to configure the “compilation” process.

property original_module

Returns the original EXIR module

property processed_bytes

Returns the delegate blob created from backend.preprocess

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources