Package of one or more `ExportedPrograms` in Execution dialect. Designed to simplify lowering to ExecuTorch. See: https://pytorch.org/executorch/main/ir-exir When the ExecutorchProgramManager is constructed the ExportedPrograms in execution dialect are used to form the executorch b
| 1845 | |
| 1846 | |
| 1847 | class ExecutorchProgramManager: |
| 1848 | """ |
| 1849 | Package of one or more `ExportedPrograms` in Execution dialect. Designed to simplify |
| 1850 | lowering to ExecuTorch. See: https://pytorch.org/executorch/main/ir-exir |
| 1851 | |
| 1852 | When the ExecutorchProgramManager is constructed the ExportedPrograms in execution dialect |
| 1853 | are used to form the executorch binary (in a process called emission) and then serialized |
| 1854 | to a buffer. |
| 1855 | |
| 1856 | Manages the final link in the lowering chain of ATen -> Edge -> ExecuTorch. |
| 1857 | """ |
| 1858 | |
| 1859 | def __init__( |
| 1860 | self, |
| 1861 | execution_programs: Dict[str, ExportedProgram], |
| 1862 | config_methods: Optional[Dict[str, Any]] = None, |
| 1863 | backend_config: Optional[ExecutorchBackendConfig] = None, |
| 1864 | named_data: Optional[NamedDataStoreOutput] = None, |
| 1865 | ): |
| 1866 | """ |
| 1867 | End users should not call this constructor directly. Instead, they should use |
| 1868 | :func:'to_executorch' to construct an ExecutorchProgramManager. |
| 1869 | |
| 1870 | Constructs an ExecutorchProgramManager from a set of exported programs in |
| 1871 | execution dialect. |
| 1872 | |
| 1873 | Args: |
| 1874 | execution_programs: A dictionary of method name to the corresponding |
| 1875 | ExportedProgram. |
| 1876 | |
| 1877 | config_methods: A dictionary of method name to the config value returned |
| 1878 | by that method in eager mode. |
| 1879 | |
| 1880 | backend_config: An optional argument used to provide greater control over |
| 1881 | the emission and serialization. |
| 1882 | """ |
| 1883 | # Set up methods |
| 1884 | self._execution_programs: Dict[str, ExportedProgram] = execution_programs |
| 1885 | self._config_methods: Optional[Dict[str, Any]] = config_methods |
| 1886 | |
| 1887 | # Named data from EdgeProgramManager |
| 1888 | self._named_data: Optional[NamedDataStoreOutput] = named_data |
| 1889 | |
| 1890 | backend_config = backend_config or ExecutorchBackendConfig() |
| 1891 | |
| 1892 | # Emit methods |
| 1893 | self._emitter_output: EmitterOutput = emit_program( |
| 1894 | self._execution_programs, |
| 1895 | backend_config.emit_stacktrace, |
| 1896 | self._config_methods, |
| 1897 | backend_config.emit_mutable_buffer_names, |
| 1898 | ) |
| 1899 | |
| 1900 | # Serialize emitter output, ready to be written to a file. |
| 1901 | from executorch.extension.flat_tensor.serialize.serialize import ( |
| 1902 | FlatTensorConfig, |
| 1903 | FlatTensorSerializer, |
| 1904 | ) |