Skip to content

Commit 6b7a223

Browse files
zonglinpengfacebook-github-bot
authored andcommitted
port add ops, create new 3p buck targets, add op_add kernel modification (pytorch#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 0691ae1 commit 6b7a223

File tree

5 files changed

+159
-7
lines changed

5 files changed

+159
-7
lines changed

backends/cadence/hifi/operators/targets.bzl

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,135 @@ 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+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
47+
"//executorch/backends/cadence/hifi/kernels:kernels",
48+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
49+
],
50+
visibility = [
51+
"//executorch/backends/cadence/...",
52+
"@EXECUTORCH_CLIENTS",
53+
],
54+
)
55+
56+
57+
runtime.cxx_library(
58+
name = "op_mul",
59+
srcs = glob([
60+
"op_mul.cpp",
61+
]),
62+
platforms = CXX,
63+
deps = [
64+
"//executorch/kernels/portable/cpu/util:all_deps",
65+
"//executorch/kernels/portable/cpu/pattern:all_deps",
66+
"//executorch/runtime/kernel:kernel_includes",
67+
"//executorch/kernels/portable/cpu:scalar_utils",
68+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
69+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib_common",
70+
"//executorch/backends/cadence/hifi/kernels:kernels",
71+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
72+
],
73+
visibility = [
74+
"//executorch/backends/cadence/...",
75+
"@EXECUTORCH_CLIENTS",
76+
],
77+
)
78+
79+
runtime.cxx_library(
80+
name = "op_sub",
81+
srcs = glob([
82+
"op_sub.cpp",
83+
]),
84+
platforms = CXX,
85+
deps = [
86+
"//executorch/kernels/portable/cpu/util:all_deps",
87+
"//executorch/kernels/portable/cpu/pattern:all_deps",
88+
"//executorch/runtime/kernel:kernel_includes",
89+
"//executorch/kernels/portable/cpu:scalar_utils",
90+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
91+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib_common",
92+
"//executorch/backends/cadence/hifi/kernels:kernels",
93+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
94+
],
95+
visibility = [
96+
"//executorch/backends/cadence/...",
97+
"@EXECUTORCH_CLIENTS",
98+
],
99+
)
100+
101+
runtime.cxx_library(
102+
name = "op_div",
103+
srcs = glob([
104+
"op_div.cpp",
105+
]),
106+
platforms = CXX,
107+
deps = [
108+
"//executorch/kernels/portable/cpu/util:all_deps",
109+
"//executorch/kernels/portable/cpu/pattern:all_deps",
110+
"//executorch/runtime/kernel:kernel_includes",
111+
"//executorch/kernels/portable/cpu:scalar_utils",
112+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
113+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib_common",
114+
"//executorch/backends/cadence/hifi/kernels:kernels",
115+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
116+
],
117+
visibility = [
118+
"//executorch/backends/cadence/...",
119+
"@EXECUTORCH_CLIENTS",
120+
],
121+
)
122+
123+
runtime.cxx_library(
124+
name = "op_sigmoid",
125+
srcs = glob([
126+
"op_sigmoid.cpp",
127+
]),
128+
platforms = CXX,
129+
deps = [
130+
"//executorch/kernels/portable/cpu/util:all_deps",
131+
"//executorch/kernels/portable/cpu/pattern:all_deps",
132+
"//executorch/runtime/kernel:kernel_includes",
133+
"//executorch/kernels/portable/cpu:scalar_utils",
134+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
135+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib_common",
136+
"//executorch/backends/cadence/hifi/kernels:kernels",
137+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
138+
],
139+
visibility = [
140+
"//executorch/backends/cadence/...",
141+
"@EXECUTORCH_CLIENTS",
142+
],
143+
)
144+
145+
runtime.cxx_library(
146+
name = "op_tanh",
147+
srcs = glob([
148+
"op_tanh.cpp",
149+
]),
150+
platforms = CXX,
151+
deps = [
152+
"//executorch/kernels/portable/cpu/util:all_deps",
153+
"//executorch/kernels/portable/cpu/pattern:all_deps",
154+
"//executorch/runtime/kernel:kernel_includes",
155+
"//executorch/kernels/portable/cpu:scalar_utils",
156+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
157+
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib_common",
158+
"//executorch/backends/cadence/hifi/kernels:kernels",
159+
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
160+
],
161+
visibility = [
162+
"//executorch/backends/cadence/...",
163+
"@EXECUTORCH_CLIENTS",
164+
],
165+
)
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)