diff --git a/.ci/scripts/unittest-buck2.sh b/.ci/scripts/unittest-buck2.sh index 018e23a5567..d5168cce0b2 100755 --- a/.ci/scripts/unittest-buck2.sh +++ b/.ci/scripts/unittest-buck2.sh @@ -20,5 +20,5 @@ buck2 query "//backends/apple/... + //backends/example/... + \ # TODO: expand the covered scope of Buck targets. # //runtime/kernel/... is failing because //third-party:torchgen_files's shell script can't find python on PATH. # //runtime/test/... requires Python torch, which we don't have in our OSS buck setup. -buck2 test //kernels/portable/cpu/... //runtime/backend/... //runtime/core/... \ +buck2 test //kernels/portable/... //runtime/backend/... //runtime/core/... \ //runtime/executor: //runtime/kernel/... //runtime/platform/... diff --git a/kernels/portable/targets.bzl b/kernels/portable/targets.bzl index 9e96de61c91..759e5c96ae8 100644 --- a/kernels/portable/targets.bzl +++ b/kernels/portable/targets.bzl @@ -1,4 +1,4 @@ -load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") +load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "get_aten_mode_options", "runtime") load("@fbsource//xplat/executorch/codegen:codegen.bzl", "et_operator_library", "executorch_generated_lib") def define_common_targets(): @@ -20,17 +20,18 @@ def define_common_targets(): ], ) - runtime.cxx_library( - name = "operators_aten", - srcs = [], - visibility = [ - "//executorch/...", - "@EXECUTORCH_CLIENTS", - ], - exported_deps = [ - "//executorch/kernels/portable/cpu:cpu_aten", - ], - ) + if True in get_aten_mode_options(): + runtime.cxx_library( + name = "operators_aten", + srcs = [], + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + exported_deps = [ + "//executorch/kernels/portable/cpu:cpu_aten", + ], + ) runtime.export_file( name = "functions.yaml", @@ -79,9 +80,6 @@ def define_common_targets(): ) generated_lib_common_args = { - "custom_ops_aten_kernel_deps": [ - "//executorch/kernels/portable:operators_aten", - ], "custom_ops_yaml_target": "//executorch/kernels/portable:custom_ops.yaml", # size_test expects _static targets to be available for these libraries. "define_static_targets": True, @@ -102,21 +100,22 @@ def define_common_targets(): **generated_lib_common_args ) - executorch_generated_lib( - name = "generated_lib_aten", - deps = [ - ":executorch_aten_ops", - ":executorch_custom_ops", - "//executorch/kernels/portable:operators_aten", - ], - custom_ops_aten_kernel_deps = [ - "//executorch/kernels/portable:operators_aten", - ], - custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml", - aten_mode = True, - visibility = [ - "//executorch/...", - "@EXECUTORCH_CLIENTS", - ], - define_static_targets = True, - ) + if True in get_aten_mode_options(): + executorch_generated_lib( + name = "generated_lib_aten", + deps = [ + ":executorch_aten_ops", + ":executorch_custom_ops", + "//executorch/kernels/portable:operators_aten", + ], + custom_ops_aten_kernel_deps = [ + "//executorch/kernels/portable:operators_aten", + ], + custom_ops_yaml_target = "//executorch/kernels/portable:custom_ops.yaml", + aten_mode = True, + visibility = [ + "//executorch/...", + "@EXECUTORCH_CLIENTS", + ], + define_static_targets = True, + ) diff --git a/kernels/portable/test/TARGETS b/kernels/portable/test/TARGETS index adf6636be4f..f7b89818c98 100644 --- a/kernels/portable/test/TARGETS +++ b/kernels/portable/test/TARGETS @@ -2,7 +2,6 @@ # targets.bzl. This file can contain fbcode-only targets. load(":targets.bzl", "define_common_targets") -load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") oncall("executorch") @@ -28,29 +27,3 @@ runtime.cxx_library( "libtorch", ], ) - -python_unittest( - name = "op_upsample_bilinear2d_test", - srcs = [ - "op_upsample_bilinear2d_test.py", - ], - preload_deps = [ - ":aot_ops_test_lib", - ], - deps = [ - "//caffe2:torch", - ], -) - -python_unittest( - name = "op_upsample_nearest2d_test", - srcs = [ - "op_upsample_nearest2d_test.py", - ], - preload_deps = [ - ":aot_ops_test_lib", - ], - deps = [ - "//caffe2:torch", - ], -) diff --git a/kernels/portable/test/targets.bzl b/kernels/portable/test/targets.bzl index 23f179ab690..1da276ce3f8 100644 --- a/kernels/portable/test/targets.bzl +++ b/kernels/portable/test/targets.bzl @@ -1,3 +1,4 @@ +load("@fbcode_macros//build_defs:python_unittest.bzl", "python_unittest") load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "is_xplat", "runtime") load("@fbsource//xplat/executorch/codegen:codegen.bzl", "et_operator_library", "executorch_generated_lib") load("@fbsource//xplat/executorch/kernels/test:util.bzl", "define_supported_features_lib", "op_test") @@ -8,12 +9,40 @@ def define_common_targets(): The directory containing this targets.bzl file should also contain both TARGETS and BUCK files that call this function. """ - define_supported_features_lib() + if not runtime.is_oss: + define_supported_features_lib() - op_test(name = "op_allclose_test") - op_test(name = "op_div_test") - op_test(name = "op_gelu_test") - op_test(name = "op_mul_test") + if not is_xplat(): + python_unittest( + name = "op_upsample_bilinear2d_test", + srcs = [ + "op_upsample_bilinear2d_test.py", + ], + preload_deps = [ + ":aot_ops_test_lib", + ], + deps = [ + "//caffe2:torch", + ], + ) + + python_unittest( + name = "op_upsample_nearest2d_test", + srcs = [ + "op_upsample_nearest2d_test.py", + ], + preload_deps = [ + ":aot_ops_test_lib", + ], + deps = [ + "//caffe2:torch", + ], + ) + + op_test(name = "op_allclose_test") + op_test(name = "op_div_test") + op_test(name = "op_gelu_test") + op_test(name = "op_mul_test") if is_xplat(): et_operator_library( diff --git a/runtime/core/portable_type/c10/c10/targets.bzl b/runtime/core/portable_type/c10/c10/targets.bzl index 2bde5eac5e4..a727cb19ac1 100644 --- a/runtime/core/portable_type/c10/c10/targets.bzl +++ b/runtime/core/portable_type/c10/c10/targets.bzl @@ -29,21 +29,11 @@ def define_common_targets(): "util/irange.h", ], exported_preprocessor_flags = [ - # NOTE: If we define C10_EMBEDDED to prevent Half and - # BFloat16 from supporting streams, non-ExecuTorch-core - # uses of other ATen headers that try to print ATen - # primitive types fail to build because, apparently, there - # are implicit conversions from Half/BFloat16 to a variety - # of primitive types, not just float. Since merely - # including shouldn't result in any runtime - # artifacts if stream code is never actually called, it - # seems best to just not define C10_EMBEDDED, but if you - # need it, it's there. - # "-DC10_EMBEDDED", + "-DC10_USING_CUSTOM_GENERATED_MACROS", + ] + ([] if runtime.is_oss else [ "-DC10_USE_GLOG", "-DC10_USE_MINIMAL_GLOG", - "-DC10_USING_CUSTOM_GENERATED_MACROS", - ], + ]), visibility = [ "//executorch/...", ],