Skip to content

Commit a6eea2e

Browse files
zonglinpengfacebook-github-bot
authored andcommitted
port add ops, create new 3p buck targets, add op_add kernel modification (#6601)
Summary: Done the three things as titled - create buck targets for add mul sub div sigmoid and tanh - create new thirdparty buck targets for internal use: the OSS version is unique and leading to the GH version. by buckify the “staging” targets it’s much faster for us to get to the latest kernels. - modified cadence kernels to use the XT_ APIs Differential Revision: D65300260
1 parent 046a4e4 commit a6eea2e

File tree

5 files changed

+148
-7
lines changed

5 files changed

+148
-7
lines changed

backends/cadence/hifi/operators/targets.bzl

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,124 @@ def define_common_targets():
3131
"@EXECUTORCH_CLIENTS",
3232
],
3333
)
34+
35+
runtime.cxx_library(
36+
name = "op_add",
37+
srcs = glob([
38+
"op_add.cpp",
39+
]),
40+
platforms = CXX,
41+
deps = [
42+
"//executorch/kernels/portable/cpu/util:all_deps",
43+
"//executorch/kernels/portable/cpu/pattern:all_deps",
44+
"//executorch/runtime/kernel:kernel_includes",
45+
"//executorch/kernels/portable/cpu:scalar_utils",
46+
"//executorch/backends/cadence/hifi/kernels:kernels",
47+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
48+
],
49+
visibility = [
50+
"//executorch/backends/cadence/...",
51+
"@EXECUTORCH_CLIENTS",
52+
],
53+
)
54+
55+
56+
runtime.cxx_library(
57+
name = "op_mul",
58+
srcs = glob([
59+
"op_mul.cpp",
60+
]),
61+
platforms = CXX,
62+
deps = [
63+
"//executorch/kernels/portable/cpu/util:all_deps",
64+
"//executorch/kernels/portable/cpu/pattern:all_deps",
65+
"//executorch/runtime/kernel:kernel_includes",
66+
"//executorch/kernels/portable/cpu:scalar_utils",
67+
"//executorch/backends/cadence/hifi/kernels:kernels",
68+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
69+
],
70+
visibility = [
71+
"//executorch/backends/cadence/...",
72+
"@EXECUTORCH_CLIENTS",
73+
],
74+
)
75+
76+
runtime.cxx_library(
77+
name = "op_sub",
78+
srcs = glob([
79+
"op_sub.cpp",
80+
]),
81+
platforms = CXX,
82+
deps = [
83+
"//executorch/kernels/portable/cpu/util:all_deps",
84+
"//executorch/kernels/portable/cpu/pattern:all_deps",
85+
"//executorch/runtime/kernel:kernel_includes",
86+
"//executorch/kernels/portable/cpu:scalar_utils",
87+
"//executorch/backends/cadence/hifi/kernels:kernels",
88+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
89+
],
90+
visibility = [
91+
"//executorch/backends/cadence/...",
92+
"@EXECUTORCH_CLIENTS",
93+
],
94+
)
95+
96+
runtime.cxx_library(
97+
name = "op_div",
98+
srcs = glob([
99+
"op_div.cpp",
100+
]),
101+
platforms = CXX,
102+
deps = [
103+
"//executorch/kernels/portable/cpu/util:all_deps",
104+
"//executorch/kernels/portable/cpu/pattern:all_deps",
105+
"//executorch/runtime/kernel:kernel_includes",
106+
"//executorch/kernels/portable/cpu:scalar_utils",
107+
"//executorch/backends/cadence/hifi/kernels:kernels",
108+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
109+
],
110+
visibility = [
111+
"//executorch/backends/cadence/...",
112+
"@EXECUTORCH_CLIENTS",
113+
],
114+
)
115+
116+
runtime.cxx_library(
117+
name = "op_sigmoid",
118+
srcs = glob([
119+
"op_sigmoid.cpp",
120+
]),
121+
platforms = CXX,
122+
deps = [
123+
"//executorch/kernels/portable/cpu/util:all_deps",
124+
"//executorch/kernels/portable/cpu/pattern:all_deps",
125+
"//executorch/runtime/kernel:kernel_includes",
126+
"//executorch/kernels/portable/cpu:scalar_utils",
127+
"//executorch/backends/cadence/hifi/kernels:kernels",
128+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
129+
],
130+
visibility = [
131+
"//executorch/backends/cadence/...",
132+
"@EXECUTORCH_CLIENTS",
133+
],
134+
)
135+
136+
runtime.cxx_library(
137+
name = "op_tanh",
138+
srcs = glob([
139+
"op_tanh.cpp",
140+
]),
141+
platforms = CXX,
142+
deps = [
143+
"//executorch/kernels/portable/cpu/util:all_deps",
144+
"//executorch/kernels/portable/cpu/pattern:all_deps",
145+
"//executorch/runtime/kernel:kernel_includes",
146+
"//executorch/kernels/portable/cpu:scalar_utils",
147+
"//executorch/backends/cadence/hifi/kernels:kernels",
148+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
149+
],
150+
visibility = [
151+
"//executorch/backends/cadence/...",
152+
"@EXECUTORCH_CLIENTS",
153+
],
154+
)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
load("targets.bzl", "define_common_targets")
2+
3+
oncall("odai_jarvis")
4+
5+
define_common_targets()
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
2+
3+
load("@fbsource//tools/build_defs:platform_defs.bzl", "CXX")
4+
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")
5+
6+
def define_common_targets():
7+
runtime.cxx_library(
8+
name = "nnlib-extensions",
9+
srcs = native.glob(["*.c", "*.cpp"]),
10+
exported_headers = glob(["*.h"]),
11+
visibility = [
12+
"//executorch/backends/cadence/...",
13+
"@EXECUTORCH_CLIENTS",
14+
],
15+
deps = [
16+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
17+
],
18+
)

backends/cadence/hifi/third-party/nnlib/xa_nn_elm_add_f32_broadcast.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "xa_nnlib_err_chk.h"
2626
#include "xa_nnlib_kernels_api.h"
2727

28-
2928
#if HAVE_VFPU
3029
static void internal_elm_add_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict__ p_out,
3130
const FLOAT32 * __restrict__ p_inp1,
@@ -425,4 +424,3 @@ WORD32 xa_nn_elm_add_broadcast_4D_f32xf32_f32(FLOAT32 * __restrict__ p_out,
425424
return 0;
426425

427426
}
428-

backends/cadence/hifi/third-party/nnlib/xa_nn_elm_mul_f32_broadcast.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,10 @@
2020
2121
******************************************************************************/
2222
#include "xa_type_def.h"
23-
#include "nnlib-hifi4/xa_nnlib/algo/common/include/xa_nnlib_common_fpu.h"
24-
#include "nnlib-hifi4/xa_nnlib/algo/common/include/xa_nn_common.h"
25-
#include "nnlib-hifi4/xa_nnlib/algo/common/include/xa_nnlib_err_chk.h"
26-
#include "nnlib-hifi4/xa_nnlib/algo/kernels/basic/hifi4/xa_nn_basic_state.h"
27-
#include "nnlib-hifi4/xa_nnlib/include/nnlib/xa_nnlib_kernels_api.h"
23+
#include "xa_nnlib_common_fpu.h"
24+
#include "xa_nn_common.h"
25+
#include "xa_nnlib_err_chk.h"
26+
#include "xa_nnlib_kernels_api.h"
2827

2928
#if HAVE_VFPU
3029
static void internal_elm_mul_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict__ p_out,

0 commit comments

Comments
 (0)