Name Date Size #Lines LOC

..--

test/H25-Apr-2025-486315

README.mdH A D25-Apr-20252.2 KiB5444

TARGETSH A D25-Apr-20252.9 KiB7565

portable_lib.pyH A D25-Apr-20251.9 KiB5728

pybindings.cppH A D25-Apr-202538.9 KiB1,119933

pybindings.pyiH A D25-Apr-20258 KiB249196

README.md

1# ExecuTorch Python Module (WIP)
2This Python module, named `portable_lib`, provides a set of functions and classes for loading and executing bundled programs. To install it, run the fullowing command:
3
4```bash
5EXECUTORCH_BUILD_PYBIND=ON \
6pip install . --no-build-isolation
7```
8
9Or when installing the rest of dependencies:
10
11```bash
12install_requirements.sh --pybind
13```
14
15# Link Backends
16
17You can link the runtime against some backends to make sure a delegated or partitioned model can still run by Python module successfully:
18
19```bash
20EXECUTORCH_BUILD_PYBIND=ON \
21CMAKE_ARGS="-DEXECUTORCH_BUILD_COREML=ON -DEXECUTORCH_BUILD_MPS=ON -DEXECUTORCH_BUILD_XNNPACK=ON" \
22pip install . --no-build-isolation
23```
24
25Similarly, when installing the rest of dependencies:
26
27```bash
28install_requirements.sh --pybind coreml mps xnnpack
29```
30
31## Functions
32- `_load_for_executorch(path: str, enable_etdump: bool = False)`: Load a module from a file.
33- `_load_for_executorch_from_buffer(buffer: str, enable_etdump: bool = False)`: Load a module from a buffer.
34- `_load_for_executorch_from_bundled_program(ptr: str, enable_etdump: bool = False)`: Load a module from a bundled program.
35- `_load_bundled_program_from_buffer(buffer: str, non_const_pool_size: int = kDEFAULT_BUNDLED_INPUT_POOL_SIZE)`: Load a bundled program from a buffer.
36- `_dump_profile_results()`: Dump profile results.
37- `_get_operator_names()`: Get operator names.
38- `_create_profile_block()`: Create a profile block.
39- `_reset_profile_results()`: Reset profile results.
40## Classes
41### ExecuTorchModule
42- `load_bundled_input()`: Load bundled input.
43- `verify_result_with_bundled_expected_output(bundle: str, method_name: str, testset_idx: int, rtol: float = 1e-5, atol: float = 1e-8)`: Verify result with bundled expected output.
44- `plan_execute()`: Plan and execute.
45- `run_method()`: Run method.
46- `forward()`: Forward. This takes a pytree-flattend PyTorch-tensor-based input.
47- `has_etdump()`: Check if etdump is available.
48- `write_etdump_result_to_file()`: Write etdump result to a file.
49- `__call__()`: Call method.
50### BundledModule
51This class is currently empty and serves as a placeholder for future methods and attributes.
52## Note
53All functions and methods are guarded by a call guard that redirects `cout` and `cerr` to the Python environment.
54