From 392d88ffc51b23523b63f60888b629495b3551c9 Mon Sep 17 00:00:00 2001 From: Oscar Andersson Date: Fri, 6 Mar 2026 15:08:39 +0100 Subject: [PATCH] Move Graph/ProgramBuilder to backends/test Move GraphBuilder and ProgramBuilder to backends/test to make it accessable for other backends. Signed-off-by: Oscar Andersson Change-Id: I4ba553ea926a9d011d46632512f15a7893e28771 --- backends/cadence/aot/BUCK | 58 +++++-------------- .../aot/tests/test_decompose_ops_passes.py | 3 +- .../aot/tests/test_fusion_ops_passes.py | 3 +- .../cadence/aot/tests/test_graph_builder.py | 6 +- backends/cadence/aot/tests/test_idma_ops.py | 7 ++- .../cadence/aot/tests/test_memory_passes.py | 5 +- .../cadence/aot/tests/test_program_builder.py | 8 ++- .../cadence/aot/tests/test_quantizer_ops.py | 6 +- .../aot/tests/test_remove_ops_passes.py | 3 +- .../aot/tests/test_reorder_ops_passes.py | 3 +- .../aot/tests/test_replace_ops_passes.py | 6 +- .../aot/tests/test_simplify_ops_passes.py | 3 +- .../cadence/aot/tests/test_to_out_var_pass.py | 3 +- .../aot/tests/test_type_dispatch_passes.py | 3 +- backends/test/__init__.py | 6 ++ .../{cadence/aot => test}/graph_builder.py | 1 + .../{cadence/aot => test}/program_builder.py | 6 +- backends/test/targets.bzl | 32 ++++++++++ 18 files changed, 95 insertions(+), 67 deletions(-) create mode 100644 backends/test/__init__.py rename backends/{cadence/aot => test}/graph_builder.py (98%) rename backends/{cadence/aot => test}/program_builder.py (95%) diff --git a/backends/cadence/aot/BUCK b/backends/cadence/aot/BUCK index a17ef6cb49a..83516410232 100644 --- a/backends/cadence/aot/BUCK +++ b/backends/cadence/aot/BUCK @@ -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. @@ -216,33 +217,6 @@ 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 = [ @@ -250,7 +224,7 @@ fbcode_target(_kind = python_unittest, ], typing = True, deps = [ - ":program_builder", + "//executorch/backends/test:program_builder", "//caffe2:torch", "//later:lib", ], @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", @@ -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", ], ) @@ -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", @@ -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", @@ -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", diff --git a/backends/cadence/aot/tests/test_decompose_ops_passes.py b/backends/cadence/aot/tests/test_decompose_ops_passes.py index e4bdf42ff62..cadf539d7b3 100644 --- a/backends/cadence/aot/tests/test_decompose_ops_passes.py +++ b/backends/cadence/aot/tests/test_decompose_ops_passes.py @@ -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. @@ -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 diff --git a/backends/cadence/aot/tests/test_fusion_ops_passes.py b/backends/cadence/aot/tests/test_fusion_ops_passes.py index cc7e36b4695..6605cd86d20 100644 --- a/backends/cadence/aot/tests/test_fusion_ops_passes.py +++ b/backends/cadence/aot/tests/test_fusion_ops_passes.py @@ -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. @@ -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 diff --git a/backends/cadence/aot/tests/test_graph_builder.py b/backends/cadence/aot/tests/test_graph_builder.py index c3506dc4c07..a69d71b0ffd 100644 --- a/backends/cadence/aot/tests/test_graph_builder.py +++ b/backends/cadence/aot/tests/test_graph_builder.py @@ -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. @@ -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 diff --git a/backends/cadence/aot/tests/test_idma_ops.py b/backends/cadence/aot/tests/test_idma_ops.py index 6320bfc482b..36cf472ae51 100644 --- a/backends/cadence/aot/tests/test_idma_ops.py +++ b/backends/cadence/aot/tests/test_idma_ops.py @@ -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 diff --git a/backends/cadence/aot/tests/test_memory_passes.py b/backends/cadence/aot/tests/test_memory_passes.py index 6c8da2202d4..1e124884be6 100644 --- a/backends/cadence/aot/tests/test_memory_passes.py +++ b/backends/cadence/aot/tests/test_memory_passes.py @@ -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. @@ -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, @@ -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 ( diff --git a/backends/cadence/aot/tests/test_program_builder.py b/backends/cadence/aot/tests/test_program_builder.py index a16d42e2378..4f228bf26b5 100644 --- a/backends/cadence/aot/tests/test_program_builder.py +++ b/backends/cadence/aot/tests/test_program_builder.py @@ -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 diff --git a/backends/cadence/aot/tests/test_quantizer_ops.py b/backends/cadence/aot/tests/test_quantizer_ops.py index 831ab3b95b6..ffd28262387 100644 --- a/backends/cadence/aot/tests/test_quantizer_ops.py +++ b/backends/cadence/aot/tests/test_quantizer_ops.py @@ -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. @@ -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 ( @@ -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 diff --git a/backends/cadence/aot/tests/test_remove_ops_passes.py b/backends/cadence/aot/tests/test_remove_ops_passes.py index 3772c2dc19a..bc7529a57c7 100644 --- a/backends/cadence/aot/tests/test_remove_ops_passes.py +++ b/backends/cadence/aot/tests/test_remove_ops_passes.py @@ -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. @@ -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 ( @@ -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 diff --git a/backends/cadence/aot/tests/test_reorder_ops_passes.py b/backends/cadence/aot/tests/test_reorder_ops_passes.py index 998bfd7a676..ee0ccf25876 100644 --- a/backends/cadence/aot/tests/test_reorder_ops_passes.py +++ b/backends/cadence/aot/tests/test_reorder_ops_passes.py @@ -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. @@ -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, @@ -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 diff --git a/backends/cadence/aot/tests/test_replace_ops_passes.py b/backends/cadence/aot/tests/test_replace_ops_passes.py index 95d470644a0..71dd83ce99e 100644 --- a/backends/cadence/aot/tests/test_replace_ops_passes.py +++ b/backends/cadence/aot/tests/test_replace_ops_passes.py @@ -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. @@ -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, @@ -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 diff --git a/backends/cadence/aot/tests/test_simplify_ops_passes.py b/backends/cadence/aot/tests/test_simplify_ops_passes.py index a20b7fd535e..c40cac03591 100644 --- a/backends/cadence/aot/tests/test_simplify_ops_passes.py +++ b/backends/cadence/aot/tests/test_simplify_ops_passes.py @@ -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. @@ -12,13 +13,13 @@ import executorch.backends.cadence.aot.ops_registrations # noqa import torch -from executorch.backends.cadence.aot.graph_builder import single_op_builder from executorch.backends.cadence.aot.pass_utils import count_node from executorch.backends.cadence.aot.simplify_ops import ( BindOptionalArgsPass, SimplifySliceOpPass, ) from executorch.backends.cadence.aot.typing_stubs import expand +from executorch.backends.test.graph_builder import single_op_builder from executorch.exir.dialects._ops import ops as exir_ops from torch.fx.passes.infra.pass_base import PassBase, PassResult from torch.utils import _pytree as pytree diff --git a/backends/cadence/aot/tests/test_to_out_var_pass.py b/backends/cadence/aot/tests/test_to_out_var_pass.py index f9181f2c0bb..b5b53019a56 100644 --- a/backends/cadence/aot/tests/test_to_out_var_pass.py +++ b/backends/cadence/aot/tests/test_to_out_var_pass.py @@ -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. @@ -8,8 +9,8 @@ import executorch.backends.cadence.aot.ops_registrations # noqa import torch -from executorch.backends.cadence.aot.program_builder import ProgramBuilder from executorch.backends.cadence.aot.to_out_var_pass import CadenceToOutVarPass +from executorch.backends.test.program_builder import ProgramBuilder from executorch.exir import ExecutorchBackendConfig from executorch.exir.dialects._ops import ops as exir_ops from later.unittest import TestCase diff --git a/backends/cadence/aot/tests/test_type_dispatch_passes.py b/backends/cadence/aot/tests/test_type_dispatch_passes.py index 870735aad1a..ca02e19a0c3 100644 --- a/backends/cadence/aot/tests/test_type_dispatch_passes.py +++ b/backends/cadence/aot/tests/test_type_dispatch_passes.py @@ -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. @@ -10,10 +11,10 @@ import executorch.backends.cadence.aot.ops_registrations # noqa import torch -from executorch.backends.cadence.aot.graph_builder import single_op_builder from executorch.backends.cadence.aot.pass_utils import count_node from executorch.backends.cadence.aot.type_dispatch import CompileTimeTypeDispatchPass from executorch.backends.cadence.aot.typing_stubs import expand +from executorch.backends.test.graph_builder import single_op_builder from executorch.exir.dialects._ops import ops as exir_ops from torch.fx.passes.infra.pass_base import PassResult diff --git a/backends/test/__init__.py b/backends/test/__init__.py new file mode 100644 index 00000000000..a2155656b18 --- /dev/null +++ b/backends/test/__init__.py @@ -0,0 +1,6 @@ +# 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. + +# This package exposes testing utilities shared across backends. diff --git a/backends/cadence/aot/graph_builder.py b/backends/test/graph_builder.py similarity index 98% rename from backends/cadence/aot/graph_builder.py rename to backends/test/graph_builder.py index f609ba55472..33db1353b9a 100644 --- a/backends/cadence/aot/graph_builder.py +++ b/backends/test/graph_builder.py @@ -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. diff --git a/backends/cadence/aot/program_builder.py b/backends/test/program_builder.py similarity index 95% rename from backends/cadence/aot/program_builder.py rename to backends/test/program_builder.py index 0f4e2bc7850..44282cf936a 100644 --- a/backends/cadence/aot/program_builder.py +++ b/backends/test/program_builder.py @@ -1,11 +1,15 @@ # 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 from enum import auto, Enum from typing import Optional -from executorch.backends.cadence.aot.graph_builder import GraphBuilder +from executorch.backends.test.graph_builder import GraphBuilder from executorch.exir import EdgeCompileConfig, EdgeProgramManager from executorch.exir.pass_base import ProxyValue from executorch.exir.verification.verifier import EXIREdgeDialectVerifier diff --git a/backends/test/targets.bzl b/backends/test/targets.bzl index 6588c57fcc7..626d22aa4c2 100644 --- a/backends/test/targets.bzl +++ b/backends/test/targets.bzl @@ -1,3 +1,8 @@ +# 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. + load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") def define_common_targets(is_fbcode = False): @@ -6,6 +11,33 @@ def define_common_targets(is_fbcode = False): The directory containing this targets.bzl file should also contain both TARGETS and BUCK files that call this function. """ + runtime.python_library( + name = "graph_builder", + srcs = [ + "graph_builder.py", + ], + typing = True, + deps = [ + "//caffe2:torch", + "//executorch/exir:pass_base", + ], + ) + + runtime.python_library( + name = "program_builder", + srcs = [ + "program_builder.py", + ], + typing = True, + deps = [ + ":graph_builder", + "//caffe2:torch", + "//executorch/exir:lib", + "//executorch/exir:pass_base", + "//executorch/exir/verification:verifier", + ], + ) + if not runtime.is_oss and is_fbcode: modules_env = { "ET_XNNPACK_GENERATED_ADD_LARGE_PTE_PATH": "$(location fbcode//executorch/test/models:exported_xnnp_delegated_programs[ModuleAddLarge.pte])",