Skip to content

Commit b0c8d44

Browse files
zonglinpengfacebook-github-bot
authored andcommitted
port add ops, create new 3p buck targets, add op_add kernel modification
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 d4a9ca0 commit b0c8d44

File tree

7 files changed

+225
-35
lines changed

7 files changed

+225
-35
lines changed

backends/cadence/hifi/operators/targets.bzl

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,24 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2018-2024 Cadence Design Systems, Inc.
3+
*
4+
* Permission is hereby granted, free of charge, to any person obtaining
5+
* a copy of this software and associated documentation files (the
6+
* "Software"), to use this Software with Cadence processor cores only and
7+
* not with any other processors and platforms, subject to
8+
* the following conditions:
9+
*
10+
* The above copyright notice and this permission notice shall be included
11+
* in all copies or substantial portions of the Software.
12+
*
13+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
14+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
15+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16+
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
17+
* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
18+
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19+
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20+
21+
******************************************************************************/
122
#include "xa_type_def.h"
223
#include "xa_nnlib_common_fpu.h"
324
#include "xa_nn_common.h"

0 commit comments

Comments
 (0)