Skip to content
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: 2 additions & 1 deletion .ci/scripts/gather_test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
import os
from typing import Any

from examples.models import MODEL_NAME_TO_MODEL, MODEL_NAME_TO_OPTIONS
from examples.models import MODEL_NAME_TO_MODEL
from examples.recipes.xnnpack_optimization import MODEL_NAME_TO_OPTIONS

BUILD_TOOLS = [
"buck2",
Expand Down
2 changes: 1 addition & 1 deletion examples/backend/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def define_common_targets():
],
deps = [
"//executorch/backends/xnnpack/partition:xnnpack_partitioner",
"//executorch/examples/models:models",
"//executorch/examples/recipes/xnnpack_optimization:models",
"//executorch/examples/quantization:quant_utils",
"//executorch/exir:lib",
"//executorch/exir/backend:backend_api",
Expand Down
3 changes: 2 additions & 1 deletion examples/backend/xnnpack_examples.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@
)
from executorch.exir.backend.backend_api import to_backend

from ..models import MODEL_NAME_TO_MODEL, MODEL_NAME_TO_OPTIONS
from ..models import MODEL_NAME_TO_MODEL
from ..quantization.utils import quantize
from ..recipes.xnnpack_optimization import MODEL_NAME_TO_OPTIONS

logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
Expand Down
4 changes: 2 additions & 2 deletions examples/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from .models import MODEL_NAME_TO_MODEL, MODEL_NAME_TO_OPTIONS
from .models import MODEL_NAME_TO_MODEL

__all__ = [MODEL_NAME_TO_MODEL, MODEL_NAME_TO_OPTIONS]
__all__ = [MODEL_NAME_TO_MODEL]
14 changes: 0 additions & 14 deletions examples/models/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,17 +142,3 @@ def gen_resnet50_model_and_inputs() -> Tuple[torch.nn.Module, Any]:
"resnet18": gen_resnet18_model_and_inputs,
"resnet50": gen_resnet50_model_and_inputs,
}


@dataclass
class OptimizationOptions(object):
quantization: bool
xnnpack_delegation: bool


MODEL_NAME_TO_OPTIONS = {
"linear": OptimizationOptions(True, True),
"add": OptimizationOptions(True, True),
"add_mul": OptimizationOptions(True, True),
"mv2": OptimizationOptions(True, True),
}
5 changes: 2 additions & 3 deletions examples/quantization/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
)

from ..export.export_example import export_to_pte

from ..models import MODEL_NAME_TO_MODEL, MODEL_NAME_TO_OPTIONS

from ..models import MODEL_NAME_TO_MODEL
from ..recipes.xnnpack_optimization import MODEL_NAME_TO_OPTIONS
from .utils import quantize


Expand Down
12 changes: 12 additions & 0 deletions examples/recipes/xnnpack_optimization/TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
load("@fbcode_macros//build_defs:python_library.bzl", "python_library")

python_library(
name = "models",
srcs = [
"__init__.py",
"models.py",
],
deps = [
"//executorch/examples/models:models", # @manual
],
)
9 changes: 9 additions & 0 deletions examples/recipes/xnnpack_optimization/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from .models import MODEL_NAME_TO_OPTIONS

__all__ = [MODEL_NAME_TO_OPTIONS]
21 changes: 21 additions & 0 deletions examples/recipes/xnnpack_optimization/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

from dataclasses import dataclass


@dataclass
class OptimizationOptions(object):
quantization: bool
xnnpack_delegation: bool


MODEL_NAME_TO_OPTIONS = {
"linear": OptimizationOptions(True, True),
"add": OptimizationOptions(True, True),
"add_mul": OptimizationOptions(True, True),
"mv2": OptimizationOptions(True, True),
}