Skip to content

Move optimized target definitions to op_registration.bzl #10986

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 3 additions & 125 deletions kernels/optimized/cpu/targets.bzl
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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(
Expand Down
128 changes: 128 additions & 0 deletions shim_et/xplat/executorch/kernels/optimized/op_registration_util.bzl
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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",
],
),
)
Loading