From fd6a05fbe8f081186f892d514c30e611799bb52b Mon Sep 17 00:00:00 2001 From: Tarun Karuturi Date: Mon, 7 Oct 2024 15:13:46 -0700 Subject: [PATCH] Move xnnpack.passes to xnnpack._passes (#5917) Summary: Changing `xnnpack.passes` to `xnnpack._passes` to indicate that these passes are not covered under the API stability guarantee. Pull Request resolved: https://github.com/pytorch/executorch/pull/5917 Reviewed By: Olivia-liu, helunwencser Differential Revision: D63925008 fbshipit-source-id: 3d9f13c0a3bd61c66d07cebd62047a3e24f8af1d (cherry picked from commit 59cc8171bda588440258298fe3ed74bace7fb348) --- backends/xnnpack/TARGETS | 2 +- backends/xnnpack/{passes => _passes}/TARGETS | 0 .../xnnpack/{passes => _passes}/__init__.py | 26 +++++++++++-------- .../channels_last_tagged_reshape_pass.py | 2 +- .../conv1d_unsqueeze_pass.py | 2 +- .../{passes => _passes}/convert_to_linear.py | 0 .../{passes => _passes}/convert_to_sdpa.py | 4 +-- .../convert_to_upsample_bilinear2d.py | 2 +- .../fuse_activation_pass.py | 2 +- .../fuse_batch_norm_with_conv.py | 2 +- .../{passes => _passes}/prelu_reshape_pass.py | 2 +- .../{passes => _passes}/remove_getitem_op.py | 0 .../tag_implicit_q_dq_pass.py | 2 +- .../{passes => _passes}/xnnpack_pass.py | 0 backends/xnnpack/operators/node_visitor.py | 6 ++--- backends/xnnpack/operators/op_add.py | 2 +- backends/xnnpack/operators/op_conv2d.py | 2 +- .../operators/op_dequantize_per_tensor.py | 4 ++- backends/xnnpack/operators/op_linear.py | 2 +- backends/xnnpack/operators/op_permute.py | 6 ++--- .../operators/op_quantize_per_tensor.py | 4 ++- backends/xnnpack/operators/op_sub.py | 2 +- backends/xnnpack/operators/quant_params.py | 4 ++- .../xnnpack/partition/config/node_configs.py | 6 ++--- backends/xnnpack/test/TARGETS | 2 +- .../test/passes/test_activation_fusion.py | 4 +-- .../test/passes/test_batch_norm_fusion.py | 2 +- .../test_channels_last_tagged_reshape.py | 2 +- .../test/passes/test_convert_to_linear.py | 2 +- .../test/passes/test_remove_get_item_pass.py | 2 +- .../passes/test_tag_implicit_q_dq_pass.py | 4 ++- backends/xnnpack/test/tester/tester.py | 2 +- backends/xnnpack/xnnpack_preprocess.py | 10 ++++--- ...e-delegates-executorch-xnnpack-delegate.md | 2 +- extension/llm/export/builder.py | 2 +- 35 files changed, 66 insertions(+), 52 deletions(-) rename backends/xnnpack/{passes => _passes}/TARGETS (100%) rename backends/xnnpack/{passes => _passes}/__init__.py (73%) rename backends/xnnpack/{passes => _passes}/channels_last_tagged_reshape_pass.py (99%) rename backends/xnnpack/{passes => _passes}/conv1d_unsqueeze_pass.py (99%) rename backends/xnnpack/{passes => _passes}/convert_to_linear.py (100%) rename backends/xnnpack/{passes => _passes}/convert_to_sdpa.py (98%) rename backends/xnnpack/{passes => _passes}/convert_to_upsample_bilinear2d.py (97%) rename backends/xnnpack/{passes => _passes}/fuse_activation_pass.py (97%) rename backends/xnnpack/{passes => _passes}/fuse_batch_norm_with_conv.py (98%) rename backends/xnnpack/{passes => _passes}/prelu_reshape_pass.py (97%) rename backends/xnnpack/{passes => _passes}/remove_getitem_op.py (100%) rename backends/xnnpack/{passes => _passes}/tag_implicit_q_dq_pass.py (99%) rename backends/xnnpack/{passes => _passes}/xnnpack_pass.py (100%) diff --git a/backends/xnnpack/TARGETS b/backends/xnnpack/TARGETS index 3d53606b6f..4a3dfed762 100644 --- a/backends/xnnpack/TARGETS +++ b/backends/xnnpack/TARGETS @@ -16,8 +16,8 @@ runtime.python_library( ], deps = [ "//executorch/backends/transforms:lib", + "//executorch/backends/xnnpack/_passes:xnnpack_passes", "//executorch/backends/xnnpack/operators:operators", - "//executorch/backends/xnnpack/passes:xnnpack_passes", "//executorch/backends/xnnpack/serialization:xnnpack_serializer", "//executorch/exir:graph_module", "//executorch/exir/backend:backend_details", diff --git a/backends/xnnpack/passes/TARGETS b/backends/xnnpack/_passes/TARGETS similarity index 100% rename from backends/xnnpack/passes/TARGETS rename to backends/xnnpack/_passes/TARGETS diff --git a/backends/xnnpack/passes/__init__.py b/backends/xnnpack/_passes/__init__.py similarity index 73% rename from backends/xnnpack/passes/__init__.py rename to backends/xnnpack/_passes/__init__.py index c3a85e4aa8..00e1ba0358 100644 --- a/backends/xnnpack/passes/__init__.py +++ b/backends/xnnpack/_passes/__init__.py @@ -6,23 +6,27 @@ from typing import List, Optional, Type -from executorch.backends.xnnpack.passes.channels_last_tagged_reshape_pass import ( +from executorch.backends.xnnpack._passes.channels_last_tagged_reshape_pass import ( ChannelsLastTaggedReshapePass, ) -from executorch.backends.xnnpack.passes.conv1d_unsqueeze_pass import Conv1dUnsqueezePass -from executorch.backends.xnnpack.passes.convert_to_linear import ConvertToLinearPass -from executorch.backends.xnnpack.passes.convert_to_sdpa import ConvertToSDPAPass -from executorch.backends.xnnpack.passes.convert_to_upsample_bilinear2d import ( +from executorch.backends.xnnpack._passes.conv1d_unsqueeze_pass import ( + Conv1dUnsqueezePass, +) +from executorch.backends.xnnpack._passes.convert_to_linear import ConvertToLinearPass +from executorch.backends.xnnpack._passes.convert_to_sdpa import ConvertToSDPAPass +from executorch.backends.xnnpack._passes.convert_to_upsample_bilinear2d import ( ConvertToUpsampleBilinear2d, ) -from executorch.backends.xnnpack.passes.fuse_activation_pass import FuseActivationPass -from executorch.backends.xnnpack.passes.fuse_batch_norm_with_conv import ( +from executorch.backends.xnnpack._passes.fuse_activation_pass import FuseActivationPass +from executorch.backends.xnnpack._passes.fuse_batch_norm_with_conv import ( FuseBatchNormWithConvPass, ) -from executorch.backends.xnnpack.passes.prelu_reshape_pass import PReLUReshapePass -from executorch.backends.xnnpack.passes.remove_getitem_op import RemoveGetItemPass -from executorch.backends.xnnpack.passes.tag_implicit_q_dq_pass import TagImplicitQDqPass -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.prelu_reshape_pass import PReLUReshapePass +from executorch.backends.xnnpack._passes.remove_getitem_op import RemoveGetItemPass +from executorch.backends.xnnpack._passes.tag_implicit_q_dq_pass import ( + TagImplicitQDqPass, +) +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.exir.pass_base import ExportPass diff --git a/backends/xnnpack/passes/channels_last_tagged_reshape_pass.py b/backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py similarity index 99% rename from backends/xnnpack/passes/channels_last_tagged_reshape_pass.py rename to backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py index 692f1a9d14..89a44f303d 100644 --- a/backends/xnnpack/passes/channels_last_tagged_reshape_pass.py +++ b/backends/xnnpack/_passes/channels_last_tagged_reshape_pass.py @@ -7,7 +7,7 @@ from typing import Optional, Tuple import torch -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.utils.utils import is_param_node from executorch.exir.dialects._ops import ops as exir_ops from executorch.exir.pass_base import PassResult diff --git a/backends/xnnpack/passes/conv1d_unsqueeze_pass.py b/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py similarity index 99% rename from backends/xnnpack/passes/conv1d_unsqueeze_pass.py rename to backends/xnnpack/_passes/conv1d_unsqueeze_pass.py index 8c63d298c6..3173cab274 100644 --- a/backends/xnnpack/passes/conv1d_unsqueeze_pass.py +++ b/backends/xnnpack/_passes/conv1d_unsqueeze_pass.py @@ -7,7 +7,7 @@ from typing import Optional import torch -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.utils.quant_utils import is_dequant, is_quant from executorch.backends.xnnpack.utils.utils import get_param_tensor, is_param_node from executorch.exir.dialects._ops import ops as exir_ops diff --git a/backends/xnnpack/passes/convert_to_linear.py b/backends/xnnpack/_passes/convert_to_linear.py similarity index 100% rename from backends/xnnpack/passes/convert_to_linear.py rename to backends/xnnpack/_passes/convert_to_linear.py diff --git a/backends/xnnpack/passes/convert_to_sdpa.py b/backends/xnnpack/_passes/convert_to_sdpa.py similarity index 98% rename from backends/xnnpack/passes/convert_to_sdpa.py rename to backends/xnnpack/_passes/convert_to_sdpa.py index 97aca5491d..c7982db750 100644 --- a/backends/xnnpack/passes/convert_to_sdpa.py +++ b/backends/xnnpack/_passes/convert_to_sdpa.py @@ -9,9 +9,9 @@ import torch from executorch.backends.transforms import get_shape -from executorch.backends.xnnpack.partition.graphs import sdpa -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack.partition.graphs import sdpa from executorch.exir.dialects._ops import ops as exir_ops from torch.fx.passes.infra.pass_base import PassResult diff --git a/backends/xnnpack/passes/convert_to_upsample_bilinear2d.py b/backends/xnnpack/_passes/convert_to_upsample_bilinear2d.py similarity index 97% rename from backends/xnnpack/passes/convert_to_upsample_bilinear2d.py rename to backends/xnnpack/_passes/convert_to_upsample_bilinear2d.py index 45956ee6f6..47bff3b99e 100644 --- a/backends/xnnpack/passes/convert_to_upsample_bilinear2d.py +++ b/backends/xnnpack/_passes/convert_to_upsample_bilinear2d.py @@ -5,8 +5,8 @@ # LICENSE file in the root directory of this source tree. import torch +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.partition.graphs import bilinear_2d -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.utils.utils import check_or_raise from executorch.exir.dialects._ops import ops as exir_ops from torch.fx.passes.infra.pass_base import PassResult diff --git a/backends/xnnpack/passes/fuse_activation_pass.py b/backends/xnnpack/_passes/fuse_activation_pass.py similarity index 97% rename from backends/xnnpack/passes/fuse_activation_pass.py rename to backends/xnnpack/_passes/fuse_activation_pass.py index 797b4bb6e2..289e2b03fd 100644 --- a/backends/xnnpack/passes/fuse_activation_pass.py +++ b/backends/xnnpack/_passes/fuse_activation_pass.py @@ -7,7 +7,7 @@ import torch -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import OutputMinMax from executorch.backends.xnnpack.utils.utils import check_or_raise diff --git a/backends/xnnpack/passes/fuse_batch_norm_with_conv.py b/backends/xnnpack/_passes/fuse_batch_norm_with_conv.py similarity index 98% rename from backends/xnnpack/passes/fuse_batch_norm_with_conv.py rename to backends/xnnpack/_passes/fuse_batch_norm_with_conv.py index a2d3606826..8014edfb1c 100644 --- a/backends/xnnpack/passes/fuse_batch_norm_with_conv.py +++ b/backends/xnnpack/_passes/fuse_batch_norm_with_conv.py @@ -8,7 +8,7 @@ import torch -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.utils.utils import get_param_tensor, is_param_node from executorch.exir import ExportedProgram diff --git a/backends/xnnpack/passes/prelu_reshape_pass.py b/backends/xnnpack/_passes/prelu_reshape_pass.py similarity index 97% rename from backends/xnnpack/passes/prelu_reshape_pass.py rename to backends/xnnpack/_passes/prelu_reshape_pass.py index 86698af187..fb7f9ac982 100644 --- a/backends/xnnpack/passes/prelu_reshape_pass.py +++ b/backends/xnnpack/_passes/prelu_reshape_pass.py @@ -5,7 +5,7 @@ # LICENSE file in the root directory of this source tree. import torch -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.utils.utils import ( check_or_raise, get_param_tensor, diff --git a/backends/xnnpack/passes/remove_getitem_op.py b/backends/xnnpack/_passes/remove_getitem_op.py similarity index 100% rename from backends/xnnpack/passes/remove_getitem_op.py rename to backends/xnnpack/_passes/remove_getitem_op.py diff --git a/backends/xnnpack/passes/tag_implicit_q_dq_pass.py b/backends/xnnpack/_passes/tag_implicit_q_dq_pass.py similarity index 99% rename from backends/xnnpack/passes/tag_implicit_q_dq_pass.py rename to backends/xnnpack/_passes/tag_implicit_q_dq_pass.py index ac6ccc9b89..edbe9b44dc 100644 --- a/backends/xnnpack/passes/tag_implicit_q_dq_pass.py +++ b/backends/xnnpack/_passes/tag_implicit_q_dq_pass.py @@ -7,11 +7,11 @@ from typing import cast, List, Optional import torch +from executorch.backends.xnnpack._passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.partition.configs import ( SUPPORTED_IMPLICIT_Q_DQ_MODULES_SET, SUPPORTED_IMPLICIT_Q_DQ_OP_NAMES_SET, ) -from executorch.backends.xnnpack.passes.xnnpack_pass import XNNPACKPass from executorch.backends.xnnpack.utils.quant_utils import ( is_dequant, is_dynamic_qdq, diff --git a/backends/xnnpack/passes/xnnpack_pass.py b/backends/xnnpack/_passes/xnnpack_pass.py similarity index 100% rename from backends/xnnpack/passes/xnnpack_pass.py rename to backends/xnnpack/_passes/xnnpack_pass.py diff --git a/backends/xnnpack/operators/node_visitor.py b/backends/xnnpack/operators/node_visitor.py index 0b0eb7912a..de48748f8f 100644 --- a/backends/xnnpack/operators/node_visitor.py +++ b/backends/xnnpack/operators/node_visitor.py @@ -11,12 +11,12 @@ import torch from executorch.backends.transforms import get_shape -from executorch.backends.xnnpack.operators.quant_params import QuantParams - -from executorch.backends.xnnpack.passes.channels_last_tagged_reshape_pass import ( +from executorch.backends.xnnpack._passes.channels_last_tagged_reshape_pass import ( ChannelsLastTaggedReshapePass, ) +from executorch.backends.xnnpack.operators.quant_params import QuantParams + from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( ConstantDataOffset, PerChannelGroupQuant, diff --git a/backends/xnnpack/operators/op_add.py b/backends/xnnpack/operators/op_add.py index b4a1dac057..117e54e5cf 100644 --- a/backends/xnnpack/operators/op_add.py +++ b/backends/xnnpack/operators/op_add.py @@ -7,12 +7,12 @@ from typing import Dict import torch +from executorch.backends.xnnpack._passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) from executorch.backends.xnnpack.operators.quant_params import QuantParams -from executorch.backends.xnnpack.passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNAdd, XNNGraph, diff --git a/backends/xnnpack/operators/op_conv2d.py b/backends/xnnpack/operators/op_conv2d.py index 28da480574..62c30c010a 100644 --- a/backends/xnnpack/operators/op_conv2d.py +++ b/backends/xnnpack/operators/op_conv2d.py @@ -8,12 +8,12 @@ import torch from executorch.backends.transforms import get_shape +from executorch.backends.xnnpack._passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) from executorch.backends.xnnpack.operators.quant_params import QuantParams -from executorch.backends.xnnpack.passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNConv2d, XNNDepthwiseConv2d, diff --git a/backends/xnnpack/operators/op_dequantize_per_tensor.py b/backends/xnnpack/operators/op_dequantize_per_tensor.py index e50498318d..cea76b3105 100644 --- a/backends/xnnpack/operators/op_dequantize_per_tensor.py +++ b/backends/xnnpack/operators/op_dequantize_per_tensor.py @@ -7,12 +7,14 @@ from typing import Dict import torch +from executorch.backends.xnnpack._passes.tag_implicit_q_dq_pass import ( + TagImplicitQDqPass, +) from executorch.backends.xnnpack.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) from executorch.backends.xnnpack.operators.quant_params import QuantParams -from executorch.backends.xnnpack.passes.tag_implicit_q_dq_pass import TagImplicitQDqPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNConvert, XNNGraph, diff --git a/backends/xnnpack/operators/op_linear.py b/backends/xnnpack/operators/op_linear.py index 7fb0de8228..560f7d1a51 100644 --- a/backends/xnnpack/operators/op_linear.py +++ b/backends/xnnpack/operators/op_linear.py @@ -7,13 +7,13 @@ from typing import Dict import torch +from executorch.backends.xnnpack._passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.operators.node_visitor import ( get_input_node, NodeVisitor, register_node_visitor, ) from executorch.backends.xnnpack.operators.quant_params import QuantParams -from executorch.backends.xnnpack.passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNFullyConnected, XNNGraph, diff --git a/backends/xnnpack/operators/op_permute.py b/backends/xnnpack/operators/op_permute.py index 0d2de5b1f1..4d62d457cd 100644 --- a/backends/xnnpack/operators/op_permute.py +++ b/backends/xnnpack/operators/op_permute.py @@ -7,13 +7,13 @@ from typing import cast, Dict, List import torch +from executorch.backends.xnnpack._passes.channels_last_tagged_reshape_pass import ( + ChannelsLastTaggedReshapePass, +) from executorch.backends.xnnpack.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) -from executorch.backends.xnnpack.passes.channels_last_tagged_reshape_pass import ( - ChannelsLastTaggedReshapePass, -) from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNGraph, XNNStaticTranspose, diff --git a/backends/xnnpack/operators/op_quantize_per_tensor.py b/backends/xnnpack/operators/op_quantize_per_tensor.py index 7b6845d996..da15559410 100644 --- a/backends/xnnpack/operators/op_quantize_per_tensor.py +++ b/backends/xnnpack/operators/op_quantize_per_tensor.py @@ -7,12 +7,14 @@ from typing import Dict import torch +from executorch.backends.xnnpack._passes.tag_implicit_q_dq_pass import ( + TagImplicitQDqPass, +) from executorch.backends.xnnpack.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) from executorch.backends.xnnpack.operators.quant_params import QuantParams -from executorch.backends.xnnpack.passes.tag_implicit_q_dq_pass import TagImplicitQDqPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNConvert, XNNGraph, diff --git a/backends/xnnpack/operators/op_sub.py b/backends/xnnpack/operators/op_sub.py index 354c16fc3c..7f8a6cc962 100644 --- a/backends/xnnpack/operators/op_sub.py +++ b/backends/xnnpack/operators/op_sub.py @@ -7,12 +7,12 @@ from typing import Dict import torch +from executorch.backends.xnnpack._passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.operators.node_visitor import ( NodeVisitor, register_node_visitor, ) from executorch.backends.xnnpack.operators.quant_params import QuantParams -from executorch.backends.xnnpack.passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( XNNGraph, XNNSubtract, diff --git a/backends/xnnpack/operators/quant_params.py b/backends/xnnpack/operators/quant_params.py index 44908ac7fc..a2d26772ec 100644 --- a/backends/xnnpack/operators/quant_params.py +++ b/backends/xnnpack/operators/quant_params.py @@ -9,7 +9,9 @@ from typing import cast, Optional, Union import torch -from executorch.backends.xnnpack.passes.tag_implicit_q_dq_pass import TagImplicitQDqPass +from executorch.backends.xnnpack._passes.tag_implicit_q_dq_pass import ( + TagImplicitQDqPass, +) from executorch.backends.xnnpack.utils.quant_utils import ( extract_qdq_affine_op_args_for_decomposed_ops, is_affine_qdq, diff --git a/backends/xnnpack/partition/config/node_configs.py b/backends/xnnpack/partition/config/node_configs.py index 2449d9d644..23acfbfb8c 100644 --- a/backends/xnnpack/partition/config/node_configs.py +++ b/backends/xnnpack/partition/config/node_configs.py @@ -9,13 +9,13 @@ from typing import List, Optional import torch +from executorch.backends.xnnpack._passes.fuse_batch_norm_with_conv import ( + FuseBatchNormWithConvPass, +) from executorch.backends.xnnpack.partition.config.xnnpack_config import ( ConfigPrecisionType, XNNPartitionerConfig, ) -from executorch.backends.xnnpack.passes.fuse_batch_norm_with_conv import ( - FuseBatchNormWithConvPass, -) from executorch.backends.xnnpack.utils.utils import is_param_node from executorch.exir.backend.canonical_partitioners.config_partitioner import ( format_target_name, diff --git a/backends/xnnpack/test/TARGETS b/backends/xnnpack/test/TARGETS index 629ac8275b..11209e41ba 100644 --- a/backends/xnnpack/test/TARGETS +++ b/backends/xnnpack/test/TARGETS @@ -13,7 +13,7 @@ runtime.python_test( "test_xnnpack_utils_classes.py", ], deps = [ - "//executorch/backends/xnnpack/passes:xnnpack_passes", + "//executorch/backends/xnnpack/_passes:xnnpack_passes", "//executorch/backends/xnnpack/test/tester:tester", "//executorch/backends/xnnpack/utils:xnnpack_utils", "//executorch/exir:lib", diff --git a/backends/xnnpack/test/passes/test_activation_fusion.py b/backends/xnnpack/test/passes/test_activation_fusion.py index a9a5ead36f..a7964a3181 100644 --- a/backends/xnnpack/test/passes/test_activation_fusion.py +++ b/backends/xnnpack/test/passes/test_activation_fusion.py @@ -7,8 +7,8 @@ import unittest import torch -from executorch.backends.xnnpack.passes.convert_to_linear import ConvertToLinearPass -from executorch.backends.xnnpack.passes.fuse_activation_pass import FuseActivationPass +from executorch.backends.xnnpack._passes.convert_to_linear import ConvertToLinearPass +from executorch.backends.xnnpack._passes.fuse_activation_pass import FuseActivationPass from executorch.backends.xnnpack.test.tester import RunPasses, Tester from executorch.exir.dialects._ops import ops as exir_ops diff --git a/backends/xnnpack/test/passes/test_batch_norm_fusion.py b/backends/xnnpack/test/passes/test_batch_norm_fusion.py index 06517c526c..98e9547c47 100644 --- a/backends/xnnpack/test/passes/test_batch_norm_fusion.py +++ b/backends/xnnpack/test/passes/test_batch_norm_fusion.py @@ -8,7 +8,7 @@ from typing import Tuple import torch -from executorch.backends.xnnpack.passes.fuse_batch_norm_with_conv import ( +from executorch.backends.xnnpack._passes.fuse_batch_norm_with_conv import ( FuseBatchNormWithConvPass, ) from executorch.backends.xnnpack.test.tester import RunPasses, Tester diff --git a/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py b/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py index 36e566abc3..fe781972e3 100644 --- a/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py +++ b/backends/xnnpack/test/passes/test_channels_last_tagged_reshape.py @@ -7,7 +7,7 @@ import unittest import torch -from executorch.backends.xnnpack.passes.channels_last_tagged_reshape_pass import ( +from executorch.backends.xnnpack._passes.channels_last_tagged_reshape_pass import ( ChannelsLastTaggedReshapePass, ) from executorch.backends.xnnpack.test.test_xnnpack_utils_classes import ( diff --git a/backends/xnnpack/test/passes/test_convert_to_linear.py b/backends/xnnpack/test/passes/test_convert_to_linear.py index 0fa80246fd..a07f8cf61c 100644 --- a/backends/xnnpack/test/passes/test_convert_to_linear.py +++ b/backends/xnnpack/test/passes/test_convert_to_linear.py @@ -7,7 +7,7 @@ import unittest import torch -from executorch.backends.xnnpack.passes.convert_to_linear import ConvertToLinearPass +from executorch.backends.xnnpack._passes.convert_to_linear import ConvertToLinearPass from executorch.backends.xnnpack.test.tester import RunPasses, Tester diff --git a/backends/xnnpack/test/passes/test_remove_get_item_pass.py b/backends/xnnpack/test/passes/test_remove_get_item_pass.py index fa68c403e3..2365c9bba0 100644 --- a/backends/xnnpack/test/passes/test_remove_get_item_pass.py +++ b/backends/xnnpack/test/passes/test_remove_get_item_pass.py @@ -7,7 +7,7 @@ import unittest import torch -from executorch.backends.xnnpack.passes.remove_getitem_op import RemoveGetItemPass +from executorch.backends.xnnpack._passes.remove_getitem_op import RemoveGetItemPass from executorch.backends.xnnpack.test.tester import RunPasses, Tester diff --git a/backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py b/backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py index dc67a6582d..05d1ac9e8b 100644 --- a/backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py +++ b/backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py @@ -7,7 +7,9 @@ import unittest import torch -from executorch.backends.xnnpack.passes.tag_implicit_q_dq_pass import TagImplicitQDqPass +from executorch.backends.xnnpack._passes.tag_implicit_q_dq_pass import ( + TagImplicitQDqPass, +) from executorch.backends.xnnpack.test.tester import RunPasses, Tester from executorch.exir.backend.canonical_partitioners.duplicate_dequant_node_pass import ( DuplicateDequantNodePass, diff --git a/backends/xnnpack/test/tester/tester.py b/backends/xnnpack/test/tester/tester.py index 7586c4f231..c561f9f661 100644 --- a/backends/xnnpack/test/tester/tester.py +++ b/backends/xnnpack/test/tester/tester.py @@ -14,8 +14,8 @@ from typing import Any, Callable, Dict, List, Optional, Tuple, Type, Union import torch +from executorch.backends.xnnpack._passes import XNNPACKPassManager from executorch.backends.xnnpack.partition.xnnpack_partitioner import XnnpackPartitioner -from executorch.backends.xnnpack.passes import XNNPACKPassManager from executorch.backends.xnnpack.utils.configs import get_xnnpack_edge_compile_config from executorch.exir import ( EdgeCompileConfig, diff --git a/backends/xnnpack/xnnpack_preprocess.py b/backends/xnnpack/xnnpack_preprocess.py index b7ee440c28..4548de4940 100644 --- a/backends/xnnpack/xnnpack_preprocess.py +++ b/backends/xnnpack/xnnpack_preprocess.py @@ -9,11 +9,13 @@ from typing import Dict, final, List import torch -from executorch.backends.xnnpack.operators.node_visitor import get_node_visitors -from executorch.backends.xnnpack.passes import XNNPACKPassManager -from executorch.backends.xnnpack.passes.convert_to_linear import ConvertToLinearPass -from executorch.backends.xnnpack.passes.tag_implicit_q_dq_pass import TagImplicitQDqPass +from executorch.backends.xnnpack._passes import XNNPACKPassManager +from executorch.backends.xnnpack._passes.convert_to_linear import ConvertToLinearPass +from executorch.backends.xnnpack._passes.tag_implicit_q_dq_pass import ( + TagImplicitQDqPass, +) +from executorch.backends.xnnpack.operators.node_visitor import get_node_visitors from executorch.backends.xnnpack.serialization.xnnpack_graph_schema import ( ConstantDataOffset, diff --git a/docs/source/native-delegates-executorch-xnnpack-delegate.md b/docs/source/native-delegates-executorch-xnnpack-delegate.md index f3011316cb..b21f4c4d44 100644 --- a/docs/source/native-delegates-executorch-xnnpack-delegate.md +++ b/docs/source/native-delegates-executorch-xnnpack-delegate.md @@ -36,7 +36,7 @@ The `XnnpackPartitioner` also partitions using op targets. It traverses the grap ##### Passes -Before any serialization, we apply passes on the subgraphs to prepare the graph. These passes are essentially graph transformations that help improve the performance of the delegate. We give an overview of the most significant passes and their function below. For a description of all passes see [here](https://github.com/pytorch/executorch/tree/main/backends/xnnpack/passes): +Before any serialization, we apply passes on the subgraphs to prepare the graph. These passes are essentially graph transformations that help improve the performance of the delegate. We give an overview of the most significant passes and their function below. For a description of all passes see [here](https://github.com/pytorch/executorch/tree/main/backends/xnnpack/_passes): * Channels Last Reshape * ExecuTorch tensors tend to be contiguous before passing them into delegates, while XNNPACK only accepts channels-last memory layout. This pass minimizes the number of permutation operators inserted to pass in channels-last memory format. diff --git a/extension/llm/export/builder.py b/extension/llm/export/builder.py index 338d997297..3536f2338d 100644 --- a/extension/llm/export/builder.py +++ b/extension/llm/export/builder.py @@ -16,7 +16,7 @@ from executorch.backends.transforms.duplicate_dynamic_quant_chain import ( DuplicateDynamicQuantChainPass, ) -from executorch.backends.xnnpack.passes.convert_to_linear import ConvertToLinearPass +from executorch.backends.xnnpack._passes.convert_to_linear import ConvertToLinearPass from executorch.exir import EdgeProgramManager from executorch.exir.backend.partitioner import Partitioner