load("@fbcode_macros//build_defs:build_file_migration.bzl", "fbcode_target", "non_fbcode_target")
# Any targets that should be shared between fbcode and xplat must be defined in
# targets.bzl. This file can contain fbcode-only targets.

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

oncall("executorch")

fbcode_target(_kind = runtime.python_library,
    name = "llama_transformer",
    srcs = [
        "llama_transformer.py",
    ],
    _is_external_target = True,
    base_module = "executorch.examples.apple.coreml.llama",
    visibility = ["PUBLIC"],
    deps = [
        "//caffe2:torch",
        "//executorch/examples/models/llama:llama_transformer",
    ],
)

fbcode_target(_kind = runtime.python_library,
    name = "utils",
    srcs = [
        "utils.py",
    ],
    _is_external_target = True,
    base_module = "executorch.examples.apple.coreml.llama",
    visibility = ["PUBLIC"],
    deps = [
        "//caffe2:torch",
    ],
)

fbcode_target(_kind = runtime.python_library,
    name = "run_static_llm",
    srcs = [
        "run_static_llm.py",
    ],
    _is_external_target = True,
    base_module = "executorch.examples.apple.coreml.llama",
    visibility = ["PUBLIC"],
    deps = [
        "//caffe2:torch",
        "//executorch/examples/models/llama:transformer_modules",
        "//executorch/examples/models/llama/runner:eager_runner_library",
        "//executorch/examples/models/llama:static_attention",
        "//executorch/runtime:runtime",
        "//pytorch/tokenizers/pytorch_tokenizers:tokenizers",
    ],
)

fbcode_target(_kind = runtime.python_binary,
    name = "export",
    srcs = [
        "export.py",
    ],
    main_function = "executorch.examples.apple.coreml.llama.export.main",
    visibility = ["PUBLIC"],
    deps = [
        "fbsource//third-party/pypi/coremltools:coremltools",
        ":llama_transformer",
        ":utils",
        "//caffe2:torch",
        "//executorch/backends/apple/coreml:backend",
        "//executorch/backends/apple/coreml:partitioner",
        "//executorch/examples/models/llama:source_transformation",
        "//executorch/exir/backend:utils",
        "//executorch/exir/capture:config",
        "//executorch/exir/passes:lib",
        "//executorch/exir/passes:quant_fusion_pass",
        "//executorch/exir/passes:sym_shape_eval_pass",
        "//executorch/exir/program:program",
        "//executorch/extension/export_util:export_util",
        "//executorch/extension/llm/export:export_lib",
    ],
)
