Skip to content

Commit 35aa741

Browse files
committed
Remove to_edge_with_preserve_ops
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]
1 parent 94c4156 commit 35aa741

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,
@@ -1337,55 +1336,6 @@ def to_edge_transform_and_lower(
13371336
return edge_manager
13381337

13391338

1340-
@experimental(
1341-
"""
1342-
This is an experimental API which overloads to_edge by preserving specified ops to not be decomposed.
1343-
This function will be combined with to_edge in the future.
1344-
"""
1345-
)
1346-
def to_edge_with_preserved_ops(
1347-
programs: Union[ExportedProgram, Dict[str, ExportedProgram]],
1348-
constant_methods: Optional[Dict[str, Any]] = None,
1349-
compile_config: Optional[EdgeCompileConfig] = None,
1350-
preserve_ops: Tuple[torch._ops.OpOverload, ...] = (),
1351-
) -> "EdgeProgramManager":
1352-
"""
1353-
:func:`to_edge` constructs an EdgeProgramManager from a set of exported programs in
1354-
ATen dialect. Upon construction those programs are transformed into edge dialect.
1355-
1356-
Args:
1357-
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".
1358-
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.
1359-
compile_config: An optional argument used to provide greater control over the transformation to edge dialect process.
1360-
preserve_ops: An argument used to specify ops that should not be decomposed.
1361-
1362-
Returns:
1363-
EdgeProgramManager
1364-
"""
1365-
assert not isinstance(constant_methods, EdgeCompileConfig)
1366-
config = compile_config or EdgeCompileConfig()
1367-
if not isinstance(programs, dict):
1368-
aten_programs = {"forward": programs}
1369-
else:
1370-
aten_programs = programs
1371-
1372-
edge_programs: Dict[str, ExportedProgram] = {}
1373-
1374-
for name, program in aten_programs.items():
1375-
# Decompose to Core ATen
1376-
table = _default_decomposition_table()
1377-
for op in preserve_ops:
1378-
table.pop(op, None)
1379-
program = program.run_decompositions(table)
1380-
edge_programs[name] = _generate_edge_program(
1381-
name, config, program, preserve_ops=list(preserve_ops)
1382-
)
1383-
1384-
return EdgeProgramManager(
1385-
edge_programs, constant_methods, config, list(preserve_ops)
1386-
)
1387-
1388-
13891339
@et_logger("to_edge")
13901340
def to_edge(
13911341
programs: Union[ExportedProgram, Dict[str, ExportedProgram]],

0 commit comments

Comments
 (0)