Skip to content
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
18 changes: 12 additions & 6 deletions backends/xnnpack/recipes/xnnpack_recipe_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
from executorch.export import (
BackendRecipeProvider,
ExportRecipe,
LoweringRecipe,
QuantizationRecipe,
RecipeType,
)
Expand Down Expand Up @@ -88,12 +89,19 @@ def create_recipe(
)
return None

def _get_xnnpack_lowering_recipe(
self, precision_type: Optional[ConfigPrecisionType] = None
) -> LoweringRecipe:
return LoweringRecipe(
partitioners=[XnnpackPartitioner(precision_type=precision_type)],
edge_compile_config=get_xnnpack_edge_compile_config(),
)

def _build_fp32_recipe(self, recipe_type: RecipeType) -> ExportRecipe:
return ExportRecipe(
name=recipe_type.value,
edge_compile_config=get_xnnpack_edge_compile_config(),
lowering_recipe=self._get_xnnpack_lowering_recipe(),
executorch_backend_config=get_xnnpack_executorch_backend_config(),
partitioners=[XnnpackPartitioner()],
)

def _build_quantized_recipe(
Expand All @@ -120,9 +128,8 @@ def _build_quantized_recipe(
return ExportRecipe(
name=recipe_type.value,
quantization_recipe=quant_recipe,
edge_compile_config=get_xnnpack_edge_compile_config(),
lowering_recipe=self._get_xnnpack_lowering_recipe(precision_type),
executorch_backend_config=get_xnnpack_executorch_backend_config(),
partitioners=[XnnpackPartitioner(config_precision=precision_type)],
)

def _build_int8da_intx_weight_recipe(
Expand Down Expand Up @@ -150,9 +157,8 @@ def _build_int8da_intx_weight_recipe(
return ExportRecipe(
name=recipe_type.value,
quantization_recipe=quant_recipe,
edge_compile_config=get_xnnpack_edge_compile_config(),
lowering_recipe=self._get_xnnpack_lowering_recipe(),
executorch_backend_config=get_xnnpack_executorch_backend_config(),
partitioners=[XnnpackPartitioner()],
)

def _validate_recipe_kwargs(self, recipe_type: RecipeType, **kwargs: Any) -> None:
Expand Down
36 changes: 34 additions & 2 deletions export/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ runtime.python_library(
"//caffe2:torch",
"//executorch/exir/backend:backend_api",
"//executorch/exir:pass_manager",
"//executorch/devtools/backend_debug:delegation_info",
"//executorch/extension/export_util:export_util",
]
)
Expand All @@ -31,11 +30,35 @@ runtime.python_library(
],
deps = [
":recipe",
":stages",
":types",
"//executorch/runtime:runtime",
":recipe_registry"
]
)


runtime.python_library(
name = "stages",
srcs = [
"stages.py",
],
visibility = [
"//executorch/...",
"@EXECUTORCH_CLIENTS",
],
deps = [
":recipe",
":types",
"//executorch/devtools/backend_debug:delegation_info",
"//executorch/exir/backend:backend_api",
"//executorch/exir:pass_manager",
"//caffe2:torch",
"//executorch/devtools/backend_debug:delegation_info",
]
)


runtime.python_library(
name = "lib",
srcs = [
Expand All @@ -48,8 +71,10 @@ runtime.python_library(
deps = [
":export",
":recipe",
":stages",
":recipe_registry",
":recipe_provider"
":recipe_provider",
":types",
],
)

Expand Down Expand Up @@ -78,3 +103,10 @@ runtime.python_library(
":recipe",
]
)

runtime.python_library(
name = "types",
srcs = [
"types.py",
],
)
6 changes: 4 additions & 2 deletions export/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,15 @@
"""

from .export import export, ExportSession
from .recipe import ExportRecipe, QuantizationRecipe, RecipeType
from .recipe import ExportRecipe, LoweringRecipe, QuantizationRecipe, RecipeType
from .recipe_provider import BackendRecipeProvider
from .recipe_registry import recipe_registry

from .types import StageType

__all__ = [
"StageType",
"ExportRecipe",
"LoweringRecipe",
"QuantizationRecipe",
"ExportSession",
"export",
Expand Down
Loading
Loading