diff --git a/kernels/optimized/cpu/targets.bzl b/kernels/optimized/cpu/targets.bzl index 4b9cdef5936..0d60d2c6bee 100644 --- a/kernels/optimized/cpu/targets.bzl +++ b/kernels/optimized/cpu/targets.bzl @@ -1,127 +1,5 @@ load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") -load("@fbsource//xplat/executorch/kernels/optimized:op_registration_util.bzl", "define_op_target", "op_target") - -_OPTIMIZED_ATEN_OPS = ( - op_target( - name = "op_add", - deps = [ - ":binary_ops", - ":add_sub_impl", - "//executorch/kernels/portable/cpu:scalar_utils", - "//executorch/kernels/portable/cpu/util:broadcast_util", - ], - ), - op_target( - name = "op_bmm", - deps = [ - "//executorch/kernels/optimized:libblas", - "//executorch/kernels/portable/cpu/util:matmul_ops_util", - ], - ), - op_target( - name = "op_div", - deps = [ - ":binary_ops", - "//executorch/kernels/portable/cpu:scalar_utils", - "//executorch/kernels/portable/cpu/util:broadcast_util", - ], - ), - op_target( - name = "op_elu", - deps = [ - "//executorch/extension/threadpool:threadpool", - "//executorch/kernels/portable/cpu:scalar_utils", - "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", - ], - ), - op_target(name = "op_exp"), - op_target( - name = "op_fft_c2r", - compiler_flags = [] if runtime.is_oss else [ - "-Wno-global-constructors", - "-Wno-shadow", - ], - deps = [":fft_utils"], - ), - op_target( - name = "op_fft_r2c", - compiler_flags = [] if runtime.is_oss else [ - "-Wno-global-constructors", - "-Wno-shadow", - ], - deps = [":fft_utils"], - ), - op_target(name = "op_sigmoid"), - op_target( - name = "op_gelu", - deps = [ - "//executorch/kernels/portable/cpu/util:activation_ops_util", - "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", - ], - ), - op_target( - name = "op_le", - deps = [ - "//executorch/kernels/portable/cpu:scalar_utils", - "//executorch/kernels/portable/cpu/util:broadcast_util", - ], - ), - op_target( - name = "op_linear", - deps = [ - "//executorch/kernels/optimized:libblas", - "//executorch/kernels/portable/cpu/util:matmul_ops_util", - ], - ), - op_target( - name = "op_log_softmax", - deps = [ - "//executorch/kernels/portable/cpu/util:activation_ops_util", - "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", - ], - ), - op_target( - name = "op_mm", - deps = [ - "//executorch/kernels/optimized:libblas", - "//executorch/kernels/portable/cpu/util:matmul_ops_util", - ], - ), - op_target( - name = "op_mul", - deps = [ - ":binary_ops", - "//executorch/kernels/portable/cpu:scalar_utils", - "//executorch/kernels/portable/cpu/util:broadcast_util", - "//executorch/runtime/core/exec_aten/util:tensor_util", - ], - ), - op_target( - name = "op_native_layer_norm", - deps = [ - ":moments_utils", - "//executorch/kernels/portable/cpu/util:normalization_ops_util", - ], - ), - op_target(name = "op_neg"), - op_target( - name = "op_sub", - deps = [ - ":binary_ops", - ":add_sub_impl", - "//executorch/kernels/portable/cpu:scalar_utils", - "//executorch/kernels/portable/cpu/util:broadcast_util", - ], - ), - op_target( - name = "op_where", - deps = [ - "//executorch/extension/threadpool:threadpool", - "//executorch/kernels/portable/cpu/util:elementwise_util", - ], - ), -) - +load("@fbsource//xplat/executorch/kernels/optimized:op_registration_util.bzl", "OPTIMIZED_ATEN_OPS", "define_op_target", "op_target") def get_sleef_preprocessor_flags(): if runtime.is_oss: @@ -137,10 +15,10 @@ def define_common_targets(): """ # Define build targets for all operators registered in the tables above. - for op in _OPTIMIZED_ATEN_OPS: + for op in OPTIMIZED_ATEN_OPS: define_op_target(**op) - aten_op_targets = [":{}".format(op["name"]) for op in _OPTIMIZED_ATEN_OPS] + aten_op_targets = [":{}".format(op["name"]) for op in OPTIMIZED_ATEN_OPS] all_op_targets = aten_op_targets runtime.cxx_library( diff --git a/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl b/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl index 3ac89132380..5121dbad599 100644 --- a/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl +++ b/shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl @@ -1,3 +1,10 @@ +# Copyright (c) Meta Platforms, Inc. and affiliates. +# +# This source code is licensed under both the MIT license found in the +# LICENSE-MIT file in the root directory of this source tree and the Apache +# License, Version 2.0 found in the LICENSE-APACHE file in the root directory +# of this source tree. + load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime") load("@fbsource//xplat/executorch/build:selects.bzl", "selects") load( @@ -137,3 +144,124 @@ def define_op_target(name, compiler_flags, deps): compiler_flags = compiler_flags, deps = deps, ) + +OPTIMIZED_ATEN_OPS = ( + op_target( + name = "op_add", + deps = [ + ":binary_ops", + ":add_sub_impl", + "//executorch/kernels/portable/cpu:scalar_utils", + "//executorch/kernels/portable/cpu/util:broadcast_util", + ], + ), + op_target( + name = "op_bmm", + deps = [ + "//executorch/kernels/optimized:libblas", + "//executorch/kernels/portable/cpu/util:matmul_ops_util", + ], + ), + op_target( + name = "op_div", + deps = [ + ":binary_ops", + "//executorch/kernels/portable/cpu:scalar_utils", + "//executorch/kernels/portable/cpu/util:broadcast_util", + ], + ), + op_target( + name = "op_elu", + deps = [ + "//executorch/extension/threadpool:threadpool", + "//executorch/kernels/portable/cpu:scalar_utils", + "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", + ], + ), + op_target(name = "op_exp"), + op_target( + name = "op_fft_c2r", + compiler_flags = [] if runtime.is_oss else [ + "-Wno-global-constructors", + "-Wno-shadow", + ], + deps = [":fft_utils"], + ), + op_target( + name = "op_fft_r2c", + compiler_flags = [] if runtime.is_oss else [ + "-Wno-global-constructors", + "-Wno-shadow", + ], + deps = [":fft_utils"], + ), + op_target(name = "op_sigmoid"), + op_target( + name = "op_gelu", + deps = [ + "//executorch/kernels/portable/cpu/util:activation_ops_util", + "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", + ], + ), + op_target( + name = "op_le", + deps = [ + "//executorch/kernels/portable/cpu:scalar_utils", + "//executorch/kernels/portable/cpu/util:broadcast_util", + ], + ), + op_target( + name = "op_linear", + deps = [ + "//executorch/kernels/optimized:libblas", + "//executorch/kernels/portable/cpu/util:matmul_ops_util", + ], + ), + op_target( + name = "op_log_softmax", + deps = [ + "//executorch/kernels/portable/cpu/util:activation_ops_util", + "//executorch/runtime/core/portable_type/c10/c10:aten_headers_for_executorch", + ], + ), + op_target( + name = "op_mm", + deps = [ + "//executorch/kernels/optimized:libblas", + "//executorch/kernels/portable/cpu/util:matmul_ops_util", + ], + ), + op_target( + name = "op_mul", + deps = [ + ":binary_ops", + "//executorch/kernels/portable/cpu:scalar_utils", + "//executorch/kernels/portable/cpu/util:broadcast_util", + "//executorch/runtime/core/exec_aten/util:tensor_util", + ], + ), + op_target( + name = "op_native_layer_norm", + deps = [ + ":moments_utils", + "//executorch/kernels/portable/cpu/util:normalization_ops_util", + ], + ), + op_target(name = "op_neg"), + op_target( + name = "op_sub", + deps = [ + ":binary_ops", + ":add_sub_impl", + "//executorch/kernels/portable/cpu:scalar_utils", + "//executorch/kernels/portable/cpu/util:broadcast_util", + ], + ), + op_target( + name = "op_where", + deps = [ + "//executorch/extension/threadpool:threadpool", + "//executorch/kernels/portable/cpu/util:elementwise_util", + ], + ), +)