xref: /aosp_15_r20/external/executorch/extension/training/module/test/targets.bzl (revision 523fa7a60841cd1ecfb9cc4201f1ca8b03ed023a)
1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
2
3def define_common_targets(is_fbcode = False):
4    """Defines targets that should be shared between fbcode and xplat.
5
6    The directory containing this targets.bzl file should also contain both
7    TARGETS and BUCK files that call this function.
8    """
9
10    # TODO(dbort): Find a way to make these run for ANDROID/APPLE in xplat. The
11    # android and ios test determinators don't like the reference to the model
12    # file in fbcode. See https://fburl.com/9esapdmd
13    if not runtime.is_oss and is_fbcode:
14        modules_env = {
15            # The tests use this var to find the program file to load. This uses
16            # an fbcode target path because the authoring/export tools
17            # intentionally don't work in xplat (since they're host-only tools).
18            "ET_MODULE_ADD_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleAdd.pte])",
19            "ET_MODULE_SIMPLE_TRAIN_PATH": "$(location fbcode//executorch/test/models:exported_programs[ModuleSimpleTrain.pte])",
20        }
21
22        runtime.cxx_test(
23            name = "training_module_test",
24            srcs = [
25                "training_module_test.cpp",
26            ],
27            deps = [
28                "//executorch/extension/training/module:training_module",
29                "//executorch/extension/data_loader:file_data_loader",
30                "//executorch/runtime/core/exec_aten/testing_util:tensor_util",
31                "//executorch/kernels/portable:generated_lib",
32            ],
33            env = modules_env,
34        )
35