Skip to content
Open
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
58 changes: 16 additions & 42 deletions backends/cadence/aot/BUCK
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target")
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -216,41 +217,14 @@ fbcode_target(_kind = runtime.python_library,
],
)

fbcode_target(_kind = runtime.python_library,
name = "graph_builder",
srcs = [
"graph_builder.py",
],
typing = True,
deps = [
"fbcode//caffe2:torch",
"fbcode//executorch/exir:pass_base",
],
)

fbcode_target(_kind = runtime.python_library,
name = "program_builder",
srcs = [
"program_builder.py",
],
typing = True,
deps = [
":graph_builder",
"fbcode//caffe2:torch",
"fbcode//executorch/exir:lib",
"fbcode//executorch/exir:pass_base",
"fbcode//executorch/exir/verification:verifier",
],
)

fbcode_target(_kind = python_unittest,
name = "test_program_builder",
srcs = [
"tests/test_program_builder.py",
],
typing = True,
deps = [
":program_builder",
"//executorch/backends/test:program_builder",
"//caffe2:torch",
"//later:lib",
],
Expand Down Expand Up @@ -393,7 +367,7 @@ fbcode_target(_kind = python_unittest,
":typing_stubs",
":type_dispatch",
"//caffe2:torch",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/exir:pass_base",
"//executorch/exir/dialects:lib",
Expand Down Expand Up @@ -433,7 +407,7 @@ fbcode_target(_kind = python_unittest,
deps = [
":ops_registrations",
"//caffe2:torch",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/exir:pass_base",
"//executorch/exir/dialects:lib",
Expand All @@ -454,7 +428,7 @@ fbcode_target(_kind = python_unittest,
":replace_ops",
"//caffe2:torch",
"//executorch/backends/cadence/aot:compiler",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/exir:pass_base",
"//executorch/exir/dialects:lib",
Expand All @@ -475,7 +449,7 @@ fbcode_target(_kind = python_unittest,
"//caffe2:torch",
":typing_stubs",
"//executorch/backends/cadence/aot:compiler",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/exir:pass_base",
"//executorch/exir/dialects:lib",
Expand All @@ -496,7 +470,7 @@ fbcode_target(_kind = python_unittest,
"//caffe2:torch",
"//executorch/backends/cadence/aot:compiler",
"//executorch/backends/cadence/aot:fuse_ops",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:ops_registrations",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/exir/dialects:lib",
Expand All @@ -517,7 +491,7 @@ fbcode_target(_kind = python_unittest,
":compiler",
"//caffe2:torch",
"//executorch/backends/cadence/aot:compiler",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:ops_registrations",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/backends/cadence/aot:remove_ops",
Expand All @@ -537,7 +511,7 @@ fbcode_target(_kind = python_unittest,
":typing_stubs",
"//caffe2:torch",
"//executorch/backends/cadence/aot:compiler",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:ops_registrations",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/backends/cadence/aot:simplify_ops",
Expand All @@ -557,7 +531,7 @@ fbcode_target(_kind = python_unittest,
"//caffe2:torch",
"//executorch/backends/cadence/aot:compiler",
"//executorch/backends/cadence/aot:fuse_ops",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:ops_registrations",
"//executorch/backends/cadence/aot:pass_utils",
"//executorch/backends/cadence/aot:reorder_ops",
Expand Down Expand Up @@ -627,11 +601,11 @@ fbcode_target(_kind = python_unittest,
":typing_stubs",
":ops_registrations",
":pass_utils",
":program_builder",
"//executorch/backends/test:program_builder",
"//caffe2:torch",
"//executorch/exir:memory",
"//executorch/exir/dialects:lib",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/exir/tests:models",
],
)
Expand All @@ -643,8 +617,8 @@ fbcode_target(_kind = python_unittest,
],
typing = True,
deps = [
":program_builder",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:program_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot:ops_registrations",
"//executorch/runtime:runtime",
"//later:lib",
Expand Down Expand Up @@ -674,7 +648,7 @@ fbcode_target(_kind = python_unittest,
deps = [
"fbsource//third-party/pypi/parameterized:parameterized",
"//caffe2:torch",
"//executorch/backends/cadence/aot:graph_builder",
"//executorch/backends/test:graph_builder",
"//executorch/backends/cadence/aot/quantizer:quantizer",
"//executorch/exir:pass_base",
"//pytorch/ao:torchao",
Expand All @@ -689,7 +663,7 @@ fbcode_target(_kind = python_unittest,
typing = True,
deps = [
":ops_registrations",
":program_builder",
"//executorch/backends/test:program_builder",
":to_out_var_pass",
"//caffe2:torch",
"//executorch/exir:lib",
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/aot/tests/test_decompose_ops_passes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -11,8 +12,8 @@

import torch
from executorch.backends.cadence.aot.decompose_ops import DecomposeAtenApproxGeluPass
from executorch.backends.cadence.aot.graph_builder import single_op_builder
from executorch.backends.cadence.aot.pass_utils import count_node
from executorch.backends.test.graph_builder import single_op_builder
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.dialects.edge._ops import EdgeOpOverload
from executorch.exir.pass_base import ExportPass
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/aot/tests/test_fusion_ops_passes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand Down Expand Up @@ -28,9 +29,9 @@
FuseTransposeOrPermuteOpPairsPass,
HierarchicalCSEPass,
)
from executorch.backends.cadence.aot.graph_builder import GraphBuilder
from executorch.backends.cadence.aot.pass_utils import count_node, op_counts_match
from executorch.backends.cadence.aot.typing_stubs import expand
from executorch.backends.test.graph_builder import GraphBuilder
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.dialects.edge._ops import EdgeOpOverload
from executorch.exir.pass_base import PassResult, ProxyValue
Expand Down
6 changes: 2 additions & 4 deletions backends/cadence/aot/tests/test_graph_builder.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -11,11 +12,8 @@

import executorch.backends.cadence.aot.ops_registrations # noqa
import torch
from executorch.backends.cadence.aot.graph_builder import (
GraphBuilder,
single_op_builder,
)
from executorch.backends.cadence.aot.pass_utils import count_node
from executorch.backends.test.graph_builder import GraphBuilder, single_op_builder
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import ExportPass, NodeMetadata
from later.unittest import TestCase
Expand Down
7 changes: 6 additions & 1 deletion backends/cadence/aot/tests/test_idma_ops.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.


# pyre-strict

import executorch.backends.cadence.aot.ops_registrations # noqa
import torch

from executorch.backends.cadence.aot.graph_builder import GraphBuilder
from executorch.backends.test.graph_builder import GraphBuilder
from executorch.exir.dialects._ops import ops as exir_ops

from later.unittest import TestCase
Expand Down
5 changes: 3 additions & 2 deletions backends/cadence/aot/tests/test_memory_passes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -14,7 +15,6 @@
import executorch.backends.cadence.aot.ops_registrations # noqa
import torch
from executorch.backends.cadence.aot import compiler
from executorch.backends.cadence.aot.graph_builder import GraphBuilder
from executorch.backends.cadence.aot.memory_constraints import (
ConstraintsGenPass,
MemConstraints,
Expand All @@ -33,12 +33,13 @@
count_node,
register_cadence_pass,
)
from executorch.backends.cadence.aot.program_builder import ProgramBuilder
from executorch.backends.cadence.aot.typing_stubs import expand
from executorch.backends.cadence.aot.utils import (
get_default_memory_config,
MemoryConfig,
)
from executorch.backends.test.graph_builder import GraphBuilder
from executorch.backends.test.program_builder import ProgramBuilder
from executorch.exir import EdgeProgramManager, ExportedProgram
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.memory_planning import (
Expand Down
8 changes: 6 additions & 2 deletions backends/cadence/aot/tests/test_program_builder.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.

# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
#
# pyre-strict
import torch
from executorch.backends.cadence.aot.program_builder import IrMode, ProgramBuilder
from executorch.backends.test.program_builder import IrMode, ProgramBuilder
from executorch.exir.dialects._ops import ops as exir_ops
from later.unittest import TestCase
from torch._export.verifier import SpecViolationError
Expand Down
6 changes: 2 additions & 4 deletions backends/cadence/aot/tests/test_quantizer_ops.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -11,10 +12,6 @@
from typing import Callable

import torch
from executorch.backends.cadence.aot.graph_builder import (
GraphBuilder,
single_op_builder,
)
from executorch.backends.cadence.aot.quantizer import quantizer as quantizer_module
from executorch.backends.cadence.aot.quantizer.patterns import AddmmPattern
from executorch.backends.cadence.aot.quantizer.quantizer import (
Expand All @@ -35,6 +32,7 @@
qconfig_A8W8,
qconfig_A8W8sym,
)
from executorch.backends.test.graph_builder import GraphBuilder, single_op_builder
from executorch.exir.pass_base import NodeMetadata
from parameterized import parameterized
from torch._ops import OpOverload
Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/aot/tests/test_remove_ops_passes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -14,7 +15,6 @@
import executorch.backends.cadence.aot.ops_registrations # noqa
import torch
from executorch.backends.cadence.aot.fuse_ops import FuseQuantDequantToRequantizePass
from executorch.backends.cadence.aot.graph_builder import GraphBuilder

from executorch.backends.cadence.aot.pass_utils import count_node
from executorch.backends.cadence.aot.remove_ops import (
Expand All @@ -36,6 +36,7 @@
RemoveZeroSizedConstantPadNd,
)
from executorch.backends.cadence.aot.typing_stubs import expand
from executorch.backends.test.graph_builder import GraphBuilder
from executorch.exir.dialects._ops import ops as exir_ops
from pyre_extensions import none_throws

Expand Down
3 changes: 2 additions & 1 deletion backends/cadence/aot/tests/test_reorder_ops_passes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -13,7 +14,6 @@
import executorch.backends.cadence.aot.ops_registrations # noqa
import torch
from executorch.backends.cadence.aot.fuse_ops import FuseQuantDequantToRequantizePass
from executorch.backends.cadence.aot.graph_builder import GraphBuilder
from executorch.backends.cadence.aot.pass_utils import (
count_node,
get_compute_nodes_in_gm,
Expand All @@ -28,6 +28,7 @@
PostponePermuteOpBelowSqueezeOrUnsqueezeLikeView,
SinkOpsCloserToUsePass,
)
from executorch.backends.test.graph_builder import GraphBuilder
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import PassBase, PassResult
from torch.utils import _pytree as pytree
Expand Down
6 changes: 2 additions & 4 deletions backends/cadence/aot/tests/test_replace_ops_passes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
# Copyright 2026 Arm Limited and/or its affiliates.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.
Expand All @@ -14,10 +15,6 @@
import executorch.backends.cadence.aot.ref_implementations # noqa

import torch
from executorch.backends.cadence.aot.graph_builder import (
GraphBuilder,
single_op_builder,
)
from executorch.backends.cadence.aot.pass_utils import count_node, op_counts_match
from executorch.backends.cadence.aot.replace_ops import (
MakeSliceAndCatDimOutermostPass,
Expand Down Expand Up @@ -55,6 +52,7 @@
)

from executorch.backends.cadence.aot.typing_stubs import expand
from executorch.backends.test.graph_builder import GraphBuilder, single_op_builder
from executorch.exir.dialects._ops import ops as exir_ops
from executorch.exir.pass_base import ExportPass, ProxyValue
from torch.fx.passes.infra.pass_base import PassResult
Expand Down
Loading
Loading