目录

导出至 ExecuTorch API 参考

有关API如何演变和弃用过程的详细信息,请参阅ExecuTorch API生命周期和弃用政策

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]

一个或多个ExportedPrograms的包,采用 Edge 方言。旨在简化对 ExecuTorch 的降低处理。参见:https://pytorch.org/executorch/stable/ir-exir.html

支持在一系列导出的程序上轻松应用变换,包括子图委托。

管理 ATen -> Edge -> ExecuTorch 降低链中的第二个链接。

property config_methods

返回此 EdgeProgramManager 中的配置方法集合。

exported_program(method_name='forward')[source]

返回由'method_name'指定的 ExportedProgram。

property methods

返回此 EdgeProgramManager 中的方法集合。

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

一个或多个ExportedPrograms在执行方言中的包。旨在简化对 ExecuTorch 的降低。参见:https://pytorch.org/executorch/stable/ir-exir.html

当构造 ExecutorchProgramManager 时,执行方言中的 ExportedPrograms 被用于生成 executorch 二进制文件(此过程称为发射),随后被序列化为缓冲区。

管理 ATen -> Edge -> ExecuTorch 降低链中的最终环节。

property buffer

返回序列化的 ExecuTorch 二进制文件作为字节字符串。

请注意,调用 buffer 可能会分配大量连续内存,具体取决于模型大小。如果写入文件,请使用 write_to_file,这样不会产生额外的副本。

property config_methods

返回此 ExecutorchProgramManager 中的配置方法集合。

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

以人类可读的格式打印 ExecuTorch 二进制文件。

Parameters
  • verbose (bool) – 如果为 False,则以压缩格式打印二进制文件。 如果为 True,则按模式中的规范逐字打印二进制文件。

  • out

    如果为 None,则打印到标准输出。 如果非 None,则将字符串写入该流对象。它可以是

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

exported_program(method_name='forward')[source]

返回由'method_name'指定的 ExportedProgram。

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。

文档

访问 PyTorch 的全面开发人员文档

查看文档

教程

获取面向初学者和高级开发人员的深入教程

查看教程

资源

查找开发资源并解答您的问题

查看资源