Skip to content

Move portable/util.py into extension/export_util #4141

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

Closed
wants to merge 5 commits into from
Closed
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
3 changes: 1 addition & 2 deletions examples/apple/mps/scripts/mps_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
from executorch.exir.backend.backend_api import to_backend
from executorch.exir.backend.backend_details import CompileSpec
from executorch.exir.capture._config import ExecutorchBackendConfig
from executorch.extension.export_util.utils import export_to_edge, save_pte_program
from executorch.sdk import BundledProgram, generate_etrecord
from executorch.sdk.bundled_program.config import MethodTestCase, MethodTestSuite
from executorch.sdk.bundled_program.serialize import (
Expand All @@ -32,8 +33,6 @@
from ....models import MODEL_NAME_TO_MODEL
from ....models.model_factory import EagerModelFactory

from ....portable.utils import export_to_edge, save_pte_program

FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
logging.basicConfig(level=logging.INFO, format=FORMAT)

Expand Down
2 changes: 1 addition & 1 deletion examples/arm/aot_arm_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
get_symmetric_quantization_config,
)
from executorch.exir import EdgeCompileConfig, ExecutorchBackendConfig
from executorch.extension.export_util.utils import export_to_edge, save_pte_program

# Quantize model if required using the standard export quantizaion flow.
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e

from ..models import MODEL_NAME_TO_MODEL
from ..models.model_factory import EagerModelFactory
from ..portable.utils import export_to_edge, save_pte_program

FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
logging.basicConfig(level=logging.WARNING, format=FORMAT)
Expand Down
2 changes: 1 addition & 1 deletion examples/models/llama2/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ runtime.python_library(
"//executorch/examples/models:model_base",
"//executorch/examples/models:models",
"//executorch/examples/models/llama2/custom_ops:custom_ops_aot_py",
"//executorch/examples/portable:utils",
"//executorch/exir:lib",
"//executorch/extension/llm/export:export_lib",
"//executorch/extension/export_util:export_util",
# one definition has to be included in the user of the libarary
# depending on what library the client wants to use
# "//executorch/extension/pybindings:aten_lib",
Expand Down
10 changes: 2 additions & 8 deletions examples/models/llama2/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@
from typing import Any, Callable, List, Optional

import torch

try:
from ...portable.utils import export_to_edge, save_pte_program
except ImportError:
# Workaround to bypass the different paths between executorch pip package and directly python call
# TODO: remove this try catch workaround and have a standard wa to import portable.utils
# pyre-ignore: Undefined import [21]: Could not find a module corresponding to import `examples.portable.utils`.
from examples.portable.utils import export_to_edge, save_pte_program
from executorch.backends.transforms.duplicate_dynamic_quant_chain import (
DuplicateDynamicQuantChainPass,
)
Expand All @@ -33,6 +25,8 @@
from executorch.exir.passes import MemoryPlanningPass
from executorch.exir.passes.quant_fusion_pass import QuantFusionPass
from executorch.exir.passes.sym_shape_eval_pass import ConstraintBasedSymShapeEvalPass

from executorch.extension.export_util.utils import export_to_edge, save_pte_program
from torch._export import capture_pre_autograd_graph
from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
from torch.ao.quantization.quantizer import Quantizer
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@
from executorch.examples.models import MODEL_NAME_TO_MODEL
from executorch.examples.models.model_factory import EagerModelFactory

from executorch.extension.export_util.utils import export_to_edge

from executorch.extension.pybindings.portable_lib import ( # @manual
_load_for_executorch_from_buffer,
)

from ..utils import export_to_edge


class ExportTest(unittest.TestCase):
def collect_executorch_and_eager_outputs(
Expand Down
6 changes: 5 additions & 1 deletion examples/portable/scripts/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@
import torch

from executorch.exir.capture import EdgeCompileConfig, ExecutorchBackendConfig
from executorch.extension.export_util.utils import (
export_to_edge,
export_to_exec_prog,
save_pte_program,
)

from ...models import MODEL_NAME_TO_MODEL
from ...models.model_factory import EagerModelFactory
from ..utils import export_to_edge, export_to_exec_prog, save_pte_program


FORMAT = "[%(levelname)s %(asctime)s %(filename)s:%(lineno)s] %(message)s"
Expand Down
2 changes: 1 addition & 1 deletion examples/qualcomm/scripts/export_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
)
from executorch.examples.models import MODEL_NAME_TO_MODEL
from executorch.examples.models.model_factory import EagerModelFactory
from executorch.examples.portable.utils import save_pte_program
from executorch.exir.backend.backend_api import to_backend, validation_disabled
from executorch.exir.capture._config import ExecutorchBackendConfig
from executorch.extension.export_util.utils import save_pte_program
from executorch.sdk import generate_etrecord

from torch.ao.quantization.quantize_pt2e import convert_pt2e, prepare_pt2e
Expand Down
2 changes: 1 addition & 1 deletion examples/sdk/scripts/export_bundled_program.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import torch

from executorch.exir import ExecutorchProgramManager
from executorch.extension.export_util.utils import export_to_exec_prog
from executorch.sdk import BundledProgram
from executorch.sdk.bundled_program.config import (
MethodInputType,
Expand All @@ -25,7 +26,6 @@

from ...models import MODEL_NAME_TO_MODEL
from ...models.model_factory import EagerModelFactory
from ...portable.utils import export_to_exec_prog


def save_bundled_program(
Expand Down
2 changes: 1 addition & 1 deletion examples/xnnpack/aot_compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
import torch
from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner
from executorch.exir import EdgeCompileConfig, ExecutorchBackendConfig
from executorch.extension.export_util.utils import export_to_edge, save_pte_program
from executorch.sdk import generate_etrecord

from ..models import MODEL_NAME_TO_MODEL
from ..models.model_factory import EagerModelFactory
from ..portable.utils import export_to_edge, save_pte_program
from . import MODEL_NAME_TO_OPTIONS
from .quantization.utils import quantize

Expand Down
2 changes: 1 addition & 1 deletion examples/xnnpack/quantization/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import torch
from executorch.exir import EdgeCompileConfig
from executorch.exir.capture._config import ExecutorchBackendConfig
from executorch.extension.export_util.utils import export_to_edge, save_pte_program
from torch.ao.ns.fx.utils import compute_sqnr
from torch.ao.quantization import ( # @manual
default_per_channel_symmetric_qnnpack_qconfig,
Expand All @@ -30,7 +31,6 @@

from ...models import MODEL_NAME_TO_MODEL
from ...models.model_factory import EagerModelFactory
from ...portable.utils import export_to_edge, save_pte_program

from .. import MODEL_NAME_TO_OPTIONS
from .utils import quantize
Expand Down
2 changes: 1 addition & 1 deletion examples/xnnpack/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def define_common_targets():
deps = [
":models",
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
"//executorch/examples/portable:utils",
"//executorch/extension/export_util:export_util",
"//executorch/examples/xnnpack/quantization:quant_utils",
"//executorch/exir:lib",
"//executorch/exir/backend:backend_api",
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ addopts =
# For GitHub testing this is setup/executed in the unittest-arm job see .github/workflows/pull.yml for more info.
--ignore-glob=backends/arm/**/*
# explicitly list out tests that are running successfully in oss
examples/portable/test
examples/models/test
# sdk/
sdk/
# examples
Expand Down
Loading