Skip to content

[ET] promote to_edge_transform_and_lower to public API #4766

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion backends/vulkan/test/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ python_unittest(
"//executorch/backends/vulkan:vulkan_preprocess",
"//executorch/backends/vulkan/partitioner:vulkan_partitioner",
"//executorch/exir:lib",
"//executorch/exir/program:program",
"//executorch/extension/pybindings:portable_lib", # @manual
"//executorch/extension/pytree:pylib",
"//executorch/kernels/portable:custom_ops_generated_lib",
Expand Down
4 changes: 2 additions & 2 deletions backends/vulkan/test/test_vulkan_delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
ctypes.CDLL("libvulkan.so.1")


from executorch.exir.program._program import _to_edge_transform_and_lower
from executorch.exir import to_edge_transform_and_lower
from executorch.extension.pybindings.portable_lib import ( # @manual
_load_for_executorch_from_buffer,
)
Expand Down Expand Up @@ -120,7 +120,7 @@ def run_test(memory_layout):
model, sample_inputs, dynamic_shapes=dynamic_shapes
)

edge_program = _to_edge_transform_and_lower(
edge_program = to_edge_transform_and_lower(
program,
transform_passes=[
I64toI32(self._edge_compile_config._skip_dim_order),
Expand Down
4 changes: 2 additions & 2 deletions backends/xnnpack/test/tester/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
ExecutorchBackendConfig,
ExecutorchProgramManager,
to_edge,
to_edge_transform_and_lower,
)
from executorch.exir.backend.backend_api import validation_disabled
from executorch.exir.backend.partitioner import Partitioner
from executorch.exir.passes.sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass
from executorch.exir.print_program import pretty_print, print_program
from executorch.exir.program._program import _to_edge_transform_and_lower

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down Expand Up @@ -300,7 +300,7 @@ def __init__(

def run(self, artifact: ExportedProgram, inputs=None) -> None:
artifact_to_run = copy.deepcopy(artifact)
self.edge_dialect_program = _to_edge_transform_and_lower(
self.edge_dialect_program = to_edge_transform_and_lower(
artifact_to_run,
compile_config=self.edge_compile_conf,
partitioner=self.partitioners,
Expand Down
5 changes: 2 additions & 3 deletions examples/models/llava/export_llava.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@
replace_sdpa_with_custom_op,
)
from executorch.examples.models.llava.model import LlavaModel
from executorch.exir import EdgeCompileConfig
from executorch.exir.program._program import _to_edge_transform_and_lower
from executorch.exir import EdgeCompileConfig, to_edge_transform_and_lower

from executorch.extension.llm.export.builder import DType, LLMEdgeManager
from torch.ao.quantization.quantizer.xnnpack_quantizer import (
Expand Down Expand Up @@ -182,7 +181,7 @@ def export_all(llava_model: LlavaModel):

token_embedding_ep = export_token_embedding(llava, prompt_before_image)

lowered_and_edge = _to_edge_transform_and_lower(
lowered_and_edge = to_edge_transform_and_lower(
{
"image_encoder": image_encoder_ep,
"token_embedding": token_embedding_ep,
Expand Down
2 changes: 2 additions & 0 deletions exir/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
ExecutorchProgramManager,
ExirExportedProgram,
to_edge,
to_edge_transform_and_lower,
)
from executorch.exir.serde.serialize import load, save
from executorch.exir.tracer import ExirDynamoConfig
Expand All @@ -42,6 +43,7 @@
"ExportGraphSignature",
"_to_edge",
"to_edge",
"to_edge_transform_and_lower",
"EdgeProgramManager",
"ExecutorchProgramManager",
"edge_to_executorch_passes",
Expand Down
4 changes: 2 additions & 2 deletions exir/program/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@
from executorch.exir.program._fake_program import get_fake_program
from executorch.exir.program._program import (
_to_edge,
_to_edge_transform_and_lower,
edge_to_executorch_passes,
EdgeProgramManager,
ExecutorchProgram,
ExecutorchProgramManager,
ExirExportedProgram,
to_edge,
to_edge_transform_and_lower,
)

__all__ = [
"ExirExportedProgram",
"ExecutorchProgram",
"_to_edge",
"to_edge",
"_to_edge_transform_and_lower",
"to_edge_transform_and_lower",
"edge_to_executorch_passes",
"EdgeProgramManager",
"ExecutorchProgramManager",
Expand Down
2 changes: 1 addition & 1 deletion exir/program/_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -926,7 +926,7 @@ def _gen_edge_manager_for_partitioners(
return edge_manager


def _to_edge_transform_and_lower(
def to_edge_transform_and_lower(
programs: Union[ExportedProgram, Dict[str, ExportedProgram]],
transform_passes: Optional[
Union[Sequence[PassType], Dict[str, Sequence[PassType]]]
Expand Down
8 changes: 4 additions & 4 deletions exir/program/test/test_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@
from executorch.exir.pass_base import ExportPass
from executorch.exir.passes import MemoryPlanningPass
from executorch.exir.program._program import (
_to_edge_transform_and_lower,
EdgeProgramManager,
ExecutorchProgramManager,
to_edge,
to_edge_transform_and_lower,
)
from executorch.exir.tracer import _default_decomposition_table
from executorch.exir.verification.verifier import EXIREdgeDialectVerifier
Expand Down Expand Up @@ -587,7 +587,7 @@ def get_num_nondecomposed_ops(self, ep, partitioner):

def _test_model_with_non_decomp_partitioner(self, model: torch.nn.Module):
# This is the pre-dispatch export that we will be switching to primarily
# in the near future. The input to _to_edge_transform_and_lower needs to
# in the near future. The input to to_edge_transform_and_lower needs to
# be a graph generated by this pre dispatch export.
ep = _export(model, model._get_random_inputs(), pre_dispatch=True)
non_decomp_partitioner = NonDecompTestPartitioner()
Expand All @@ -597,7 +597,7 @@ def _test_model_with_non_decomp_partitioner(self, model: torch.nn.Module):
)

# run to_edge_trasnform_and_lower
edge = _to_edge_transform_and_lower(
edge = to_edge_transform_and_lower(
ep,
compile_config=EdgeCompileConfig(),
partitioner=[NonDecompTestPartitioner()],
Expand Down Expand Up @@ -652,7 +652,7 @@ def _get_random_inputs(cls):

model = TestLinear()
ep = _export(model, model._get_random_inputs(), pre_dispatch=True)
edge = _to_edge_transform_and_lower(
edge = to_edge_transform_and_lower(
ep,
compile_config=EdgeCompileConfig(),
partitioner=[NonDecompTestPartitioner()],
Expand Down
Loading