Skip to content

Commit 4500419

Browse files
authored
Remove to_edge_with_preserve_ops (#12614)
Experimental API, no stability guarantees. Replaced with to_edge, which now takes in `preserve_ops` in the `EdgeCompileConfig`. Differential Revision: [D78312326](https://our.internmc.facebook.com/intern/diff/D78312326/) [ghstack-poisoned] ### Summary [PLEASE REMOVE] See [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests) for ExecuTorch PR guidelines. [PLEASE REMOVE] If this PR closes an issue, please add a `Fixes #<issue-id>` line. [PLEASE REMOVE] If this PR introduces a fix or feature that should be the upcoming release notes, please add a "Release notes: <area>" label. For a list of available release notes labels, check out [CONTRIBUTING.md's Pull Requests](https://github.com/pytorch/executorch/blob/main/CONTRIBUTING.md#pull-requests). ### Test plan [PLEASE REMOVE] How did you test this PR? Please write down any manual commands you used and note down tests that you have written if applicable.
1 parent 6c51181 commit 4500419

File tree

1 file changed

+1
-51
lines changed

1 file changed

+1
-51
lines changed

exir/program/_program.py

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import io
1212
import logging
1313
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
1515

1616
import torch
1717
import torch._export
@@ -22,7 +22,6 @@
2222
)
2323
from executorch.exir._serialize._serialize import serialize_for_executorch
2424
from executorch.exir._serialize.data_serializer import DataSerializer
25-
from executorch.exir._warnings import experimental
2625
from executorch.exir.backend.backend_api import (
2726
MethodProgramsPartitionerSpec,
2827
to_backend,
@@ -1299,55 +1298,6 @@ def to_edge_transform_and_lower(
12991298
return edge_manager
13001299

13011300

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-
13511301
@et_logger("to_edge")
13521302
def to_edge(
13531303
programs: Union[ExportedProgram, Dict[str, ExportedProgram]],

0 commit comments

Comments
 (0)