Skip to content

Commit

Permalink
Move xnnpack.passes to xnnpack._passes (#6088)
Browse files Browse the repository at this point in the history
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: #5917

Reviewed By: Olivia-liu, helunwencser

Differential Revision: D63925008

fbshipit-source-id: 3d9f13c0a3bd61c66d07cebd62047a3e24f8af1d
(cherry picked from commit 59cc817)

Co-authored-by: Tarun Karuturi <tkaruturi@meta.com>
  • Loading branch information
pytorchbot and tarun292 authored Oct 11, 2024
1 parent a2bc6bd commit 7a2d986
Show file tree
Hide file tree
Showing 35 changed files with 66 additions and 52 deletions.
2 changes: 1 addition & 1 deletion backends/xnnpack/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
File renamed without changes.
6 changes: 3 additions & 3 deletions backends/xnnpack/operators/node_visitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/operators/op_add.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/operators/op_conv2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion backends/xnnpack/operators/op_dequantize_per_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/operators/op_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions backends/xnnpack/operators/op_permute.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion backends/xnnpack/operators/op_quantize_per_tensor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/operators/op_sub.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion backends/xnnpack/operators/quant_params.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions backends/xnnpack/partition/config/node_configs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/TARGETS
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 2 additions & 2 deletions backends/xnnpack/test/passes/test_activation_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/passes/test_batch_norm_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/passes/test_convert_to_linear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/passes/test_remove_get_item_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
4 changes: 3 additions & 1 deletion backends/xnnpack/test/passes/test_tag_implicit_q_dq_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion backends/xnnpack/test/tester/tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 6 additions & 4 deletions backends/xnnpack/xnnpack_preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion extension/llm/export/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 7a2d986

Please sign in to comment.