快捷方式

匯出 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.com.tw/executorch/stable/ir-exir.html

允許輕鬆地對匯出程式集合應用轉換,包括子圖的委託。

管理從 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.com.tw/executorch/stable/ir-exir.html

構建 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,則按照 schema 中的規範一對一列印二進位制檔案。

  • 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)

一個通用函式,根據第一個引數的型別進行分派。當前有兩個 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 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源