快捷方式

导出API参考

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

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

包含一个或多个 Edge 方言中 ExportedPrograms 的包。旨在简化向 ExecuTorch 的降低。参见:https://pytorch.ac.cn/executorch/main/ir-exir

允许轻松地跨一组导出程序应用转换,包括子图的委托。

管理 ATen -> Edge -> ExecuTorch 降低链的第二个环节。

property config_methods

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

exported_program(method_name='forward')[源代码]

返回由 'method_name' 指定的 ExportedProgram。

property methods

返回此 EdgeProgramManager 中的方法集。

class executorch.exir.ExecutorchProgramManager(execution_programs, config_methods=None, backend_config=None, named_data=None)[源代码]

包含一个或多个 Execution 方言中 ExportedPrograms 的包。旨在简化向 ExecuTorch 的降低。参见:https://pytorch.ac.cn/executorch/main/ir-exir

当 ExecutorchProgramManager 被构造时,Execution 方言中的 ExportedPrograms 被用于形成 executorch 二进制文件(在一个称为 emission 的过程中),然后被序列化到缓冲区。

管理 ATen -> Edge -> ExecuTorch 降低链的最后一个环节。

property buffer

以字节字符串形式返回序列化的 ExecuTorch 二进制文件。

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

property config_methods

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

dump_executorch_program(verbose=False, out=None)[源代码]

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

参数
  • verbose (bool) – 如果为 False,则以精简格式打印二进制文件。如果为 True,则按照规范一对一地打印二进制文件。

  • out

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

    文件对象、StringIO 对象或任何其他 TextIO 子类。

exported_program(method_name='forward')[源代码]

返回由 'method_name' 指定的 ExportedProgram。

property methods

返回此 ExecutorchProgramManager 中的方法集。

executorch.exir.backend.backend_api.to_backend(args)[源代码]
executorch.exir.backend.backend_api.to_backend(backend_id, edge_program, compile_specs)
executorch.exir.backend.backend_api.to_backend(edge_program, partitioner_instance)
executorch.exir.backend.backend_api.to_backend(method_edge_program_partitioners)

一个通用的函数,调度发生在第一个参数的类型上。目前有三个重载的 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(
    edge_program: ExportedProgram,
    partitioner: Partitioner,
) -> ExportedProgram:
class executorch.exir.backend.backend_api.LoweredBackendModule(edge_program, backend_id, processed_bytes, compile_specs, named_data_store_output=None)[源代码]

一个 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)[源代码]

返回包含序列化 ExecuTorch 二进制文件的缓冲区。

property compile_specs

返回一组特定于后端的对象,其中包含配置“编译”过程的静态元数据。

property original_module

返回原始 EXIR 模块

property processed_bytes

返回由 backend.preprocess 创建的委托 blob

文档

访问全面的 PyTorch 开发者文档

查看文档

教程

为初学者和高级开发者提供深入的教程

查看教程

资源

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

查看资源