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.

load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

oncall("executorch")

fbcode_target(_kind = runtime.python_library,
    name="replace_quant_nodes_pass",
    srcs=[
        "replace_quant_nodes_pass.py",
    ],
    deps=[
        "//caffe2:torch",
        "//executorch/exir:lib",
        "//executorch/exir:pass_base",
        "//executorch/exir/dialects:lib",
        "//executorch/backends/cortex_m/ops:ops",
        "//executorch/backends/cortex_m:utils",
    ],
)

fbcode_target(_kind = runtime.python_library,
    name="cortex_passes",
    srcs=[
        "activation_fusion_pass.py",
        "aten_to_cortex_m_pass.py",
        "clamp_hardswish_pass.py",
        "compute_quantized_constant_ops_pass.py",
        "cortex_m_pass.py",
        "cortex_m_pass_manager.py",
        "decompose_hardswish_pass.py",
        "decompose_mean_pass.py",
        "decompose_sdpa_pass.py",
        "explicit_layout_pass.py",
        "fuse_conv_padding_pass.py",
        "initialize_scratch_buffers_pass.py",
        "matmul_to_bmm_pass.py",
        "quantized_clamp_activation_pass.py",
        "scratch_buffer_sizes.py",
    ],
    deps=[
        "//caffe2:torch",
        "//executorch/backends/arm/_passes:passes",
        "//executorch/backends/cortex_m:cmsis_nn",
        "//executorch/backends/cortex_m:target_config",
        "//executorch/backends/cortex_m/ops:ops",
        "//executorch/backends/cortex_m:utils",
        "//executorch/backends/cortex_m/passes:replace_quant_nodes_pass",
        "//executorch/backends/transforms:aten_to_dialect_pass",
        "//executorch/backends/transforms:canonicalize_view_copy_permute_pass",
        "//executorch/backends/transforms:channels_last_layout",
        "//executorch/backends/transforms:channels_last_ops",
        "//executorch/backends/transforms:convert_conv1d_to_conv2d_pass",
        "//executorch/backends/transforms:remove_getitem_op",
        "//executorch/backends/transforms:remove_permutes_around_elementwise_ops",
        "//executorch/backends/transforms:remove_unused_constants_pass",
        "//executorch/backends/transforms:replace_scalar_with_tensor",
        "//executorch/backends/transforms:replace_ops_with_channels_last_variants",
        "//executorch/backends/transforms:replace_squeeze_unsqueeze_with_view",
        "//executorch/backends/transforms:utils",
        "//executorch/exir:lib",
        "//executorch/exir:pass_base",
        "//executorch/exir:pass_manager",
        "//executorch/exir/program:lib",
    ],
)
