1load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") 2load("@fbsource//xplat/executorch/kernels/optimized:op_registration_util.bzl", "define_op_target", "is_op_disabled", "op_target") 3 4_OPTIMIZED_ATEN_OPS = ( 5 op_target( 6 name = "op_add", 7 deps = [ 8 ":binary_ops", 9 "//executorch/kernels/portable/cpu:scalar_utils", 10 "//executorch/kernels/portable/cpu/util:broadcast_util", 11 ], 12 ), 13 op_target( 14 name = "op_bmm", 15 deps = [ 16 "//executorch/kernels/optimized:libblas", 17 ], 18 ), 19 op_target( 20 name = "op_div", 21 deps = [ 22 ":binary_ops", 23 "//executorch/kernels/portable/cpu:scalar_utils", 24 "//executorch/kernels/portable/cpu/util:broadcast_util", 25 ], 26 ), 27 op_target(name = "op_exp"), 28 op_target(name = "op_sigmoid"), 29 op_target( 30 name = "op_gelu", 31 deps = select({ 32 "DEFAULT": [], 33 "ovr_config//cpu:arm64": [ 34 "fbsource//third-party/sleef:sleef_arm", 35 ], 36 }), 37 ), 38 op_target( 39 name = "op_le", 40 deps = [ 41 "//executorch/kernels/portable/cpu:scalar_utils", 42 ], 43 ), 44 op_target( 45 name = "op_linear", 46 deps = [ 47 "//executorch/kernels/optimized:libblas", 48 "//executorch/kernels/portable/cpu/util:matmul_ops_util", 49 ], 50 ), 51 op_target( 52 name = "op_log_softmax", 53 deps = select({ 54 "DEFAULT": [ 55 "//executorch/kernels/portable/cpu/util:activation_ops_util", 56 ], 57 "ovr_config//cpu:arm64": [ 58 "//executorch/kernels/portable/cpu/util:activation_ops_util", 59 "fbsource//third-party/sleef:sleef_arm", 60 ], 61 }), 62 ), 63 op_target( 64 name = "op_mm", 65 deps = [ 66 "//executorch/kernels/optimized:libblas", 67 "//executorch/kernels/portable/cpu/util:matmul_ops_util", 68 ], 69 ), 70 op_target( 71 name = "op_mul", 72 deps = [ 73 ":binary_ops", 74 "//executorch/kernels/portable/cpu:scalar_utils", 75 "//executorch/kernels/portable/cpu/util:broadcast_util", 76 "//executorch/runtime/core/exec_aten/util:tensor_util", 77 ], 78 ), 79 op_target( 80 name = "op_native_layer_norm", 81 deps = [ 82 ":moments_utils", 83 "//executorch/kernels/portable/cpu/util:normalization_ops_util", 84 ], 85 ), 86 op_target(name = "op_neg"), 87 op_target( 88 name = "op_sub", 89 deps = [ 90 ":binary_ops", 91 "//executorch/kernels/portable/cpu:scalar_utils", 92 "//executorch/kernels/portable/cpu/util:broadcast_util", 93 ], 94 ), 95) 96 97def define_common_targets(): 98 """Defines targets that should be shared between fbcode and xplat. 99 100 The directory containing this targets.bzl file should also contain both 101 TARGETS and BUCK files that call this function. 102 """ 103 104 enabled_ops = [op for op in _OPTIMIZED_ATEN_OPS if not is_op_disabled(op["name"])] 105 106 # Define build targets for all operators registered in the tables above. 107 for op in enabled_ops: 108 define_op_target(**op) 109 110 aten_op_targets = [":{}".format(op["name"]) for op in enabled_ops] 111 all_op_targets = aten_op_targets 112 113 runtime.cxx_library( 114 name = "binary_ops", 115 exported_headers = ["binary_ops.h"], 116 visibility = ["//executorch/kernels/optimized/cpu/..."], 117 exported_deps = ["//executorch/runtime/core:core"], 118 ) 119 120 runtime.cxx_library( 121 name = "cpu_optimized", 122 srcs = [], 123 visibility = ["//executorch/kernels/..."], 124 exported_deps = all_op_targets, 125 ) 126 127 runtime.cxx_library( 128 name = "moments_utils", 129 srcs = [], 130 exported_headers = ["moments_utils.h"], 131 visibility = ["//executorch/kernels/optimized/..."], 132 exported_deps = [ 133 "//executorch/kernels/optimized:libvec", 134 "//executorch/kernels/optimized:libutils", 135 ], 136 ) 137