|
11 | 11 | import io |
12 | 12 | import logging |
13 | 13 | import os |
14 | | -from typing import Any, Dict, List, Optional, Sequence, Set, TextIO, Tuple, Type, Union |
| 14 | +from typing import Any, Dict, List, Optional, Sequence, Set, TextIO, Type, Union |
15 | 15 |
|
16 | 16 | import torch |
17 | 17 | import torch._export |
|
22 | 22 | ) |
23 | 23 | from executorch.exir._serialize._serialize import serialize_for_executorch |
24 | 24 | from executorch.exir._serialize.data_serializer import DataSerializer |
25 | | -from executorch.exir._warnings import experimental |
26 | 25 | from executorch.exir.backend.backend_api import ( |
27 | 26 | MethodProgramsPartitionerSpec, |
28 | 27 | to_backend, |
@@ -1299,55 +1298,6 @@ def to_edge_transform_and_lower( |
1299 | 1298 | return edge_manager |
1300 | 1299 |
|
1301 | 1300 |
|
1302 | | -@experimental( |
1303 | | - """ |
1304 | | - This is an experimental API which overloads to_edge by preserving specified ops to not be decomposed. |
1305 | | - This function will be combined with to_edge in the future. |
1306 | | - """ |
1307 | | -) |
1308 | | -def to_edge_with_preserved_ops( |
1309 | | - programs: Union[ExportedProgram, Dict[str, ExportedProgram]], |
1310 | | - constant_methods: Optional[Dict[str, Any]] = None, |
1311 | | - compile_config: Optional[EdgeCompileConfig] = None, |
1312 | | - preserve_ops: Tuple[torch._ops.OpOverload, ...] = (), |
1313 | | -) -> "EdgeProgramManager": |
1314 | | - """ |
1315 | | - :func:`to_edge` constructs an EdgeProgramManager from a set of exported programs in |
1316 | | - ATen dialect. Upon construction those programs are transformed into edge dialect. |
1317 | | -
|
1318 | | - Args: |
1319 | | - programs: Can be a single ExportedProgram or a dictionary mapping function names to their corresponding ExportedPrograms. If only a single ExportedProgram is provided it will be assigned the name "forward". |
1320 | | - constant_methods: An optional dictionary of method name to the constant value returned by that method in eager mode. Often used to store config information on Edge models. |
1321 | | - compile_config: An optional argument used to provide greater control over the transformation to edge dialect process. |
1322 | | - preserve_ops: An argument used to specify ops that should not be decomposed. |
1323 | | -
|
1324 | | - Returns: |
1325 | | - EdgeProgramManager |
1326 | | - """ |
1327 | | - assert not isinstance(constant_methods, EdgeCompileConfig) |
1328 | | - config = compile_config or EdgeCompileConfig() |
1329 | | - if not isinstance(programs, dict): |
1330 | | - aten_programs = {"forward": programs} |
1331 | | - else: |
1332 | | - aten_programs = programs |
1333 | | - |
1334 | | - edge_programs: Dict[str, ExportedProgram] = {} |
1335 | | - |
1336 | | - for name, program in aten_programs.items(): |
1337 | | - # Decompose to Core ATen |
1338 | | - table = _default_decomposition_table() |
1339 | | - for op in preserve_ops: |
1340 | | - table.pop(op, None) |
1341 | | - program = program.run_decompositions(table) |
1342 | | - edge_programs[name] = _generate_edge_program( |
1343 | | - name, config, program, preserve_ops=list(preserve_ops) |
1344 | | - ) |
1345 | | - |
1346 | | - return EdgeProgramManager( |
1347 | | - edge_programs, constant_methods, config, list(preserve_ops) |
1348 | | - ) |
1349 | | - |
1350 | | - |
1351 | 1301 | @et_logger("to_edge") |
1352 | 1302 | def to_edge( |
1353 | 1303 | programs: Union[ExportedProgram, Dict[str, ExportedProgram]], |
|
0 commit comments