导出到 ExecuTorch API 参考¶
有关 API 如何演变和弃用过程的详细信息,请参阅 ExecuTorch API 生命周期和弃用策略。
- class executorch.exir.EdgeProgramManager(edge_programs, constant_methods=None, compile_config=None, ops_set_to_not_decompose=None)[source]¶
Edge 方言中一个或多个 ExportedPrograms 的包。旨在简化 Lowering 到 ExecuTorch 的过程。请参阅: https://pytorch.ac.cn/executorch/stable/ir-exir.html
允许在导出的程序集合中轻松应用转换,包括子图的委托。
管理 ATen -> Edge -> ExecuTorch Lowering 链中的第二个环节。
- property config_methods¶
返回此 EdgeProgramManager 中的配置方法集。
- property methods¶
返回此 EdgeProgramManager 中的方法集。
- class executorch.exir.ExecutorchProgramManager(execution_programs, config_methods=None, backend_config=None)[source]¶
Execution 方言中一个或多个 ExportedPrograms 的包。旨在简化 Lowering 到 ExecuTorch 的过程。请参阅: https://pytorch.ac.cn/executorch/stable/ir-exir.html
当构造 ExecutorchProgramManager 时,execution 方言中的 ExportedPrograms 用于形成 executorch 二进制文件(在一个称为 emission 的过程中),然后序列化到缓冲区。
管理 ATen -> Edge -> ExecuTorch Lowering 链中的最后一个环节。
- property buffer¶
返回序列化的 ExecuTorch 二进制文件作为字节字符串。
请注意,调用 buffer 可能会分配非常大的连续内存,具体取决于模型大小。如果写入文件,请使用 write_to_file,这不会产生额外的副本。
- property config_methods¶
返回此 ExecutorchProgramManager 中的配置方法集。
- dump_executorch_program(verbose=False, out=None)[source]¶
以人类可读的格式打印 ExecuTorch 二进制文件。
- 参数
verbose (bool) – 如果为 False,则以精简格式打印二进制文件。如果为 True,则按照 schema 中的规范 1-1 打印二进制文件。
out –
如果为 None,则打印到 stdout。如果为非 None,则将字符串写入该流对象。它可以是
文件对象、StringIO 对象或任何其他 TextIO 子类。
- property methods¶
返回此 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)
根据第一个参数的类型进行调度的通用函数。当前有重载的 to_backend 函数
注意:Python 是一种动态类型语言,因此不能像方法重载那样具有适当的方法重载,因为这需要语言能够在编译时区分类型。@to_backend.register 会根据第一个参数的类型(需要类型注释)将函数附加到 to_backend()。但是,它不能接受多种类型作为参数。
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]¶
为包含委托函数的模块生成的 nn.Module 的子类。这可以通过调用 to_backend 来创建。
- property backend_id¶
返回后端名称。
- buffer(extract_delegate_segments=False, segment_alignment=128, constant_tensor_alignment=None, delegate_alignment=None, memory_planning=None)[source]¶
返回包含序列化的 ExecuTorch 二进制文件的缓冲区。
- property compile_specs¶
返回后端特定的对象列表,其中包含配置“编译”过程的静态元数据。
- property original_module¶
返回原始 EXIR 模块
- property processed_bytes¶
返回从 backend.preprocess 创建的委托 blob