Skip to content
Open
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
119 changes: 119 additions & 0 deletions backends/cadence/hifi/operators/targets.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,122 @@ def define_common_targets():
"@EXECUTORCH_CLIENTS",
],
)

runtime.cxx_library(
name = "op_add",
srcs = glob([
"op_add.cpp",
]),
platforms = CXX,
deps = [
"//executorch/kernels/portable/cpu/util:all_deps",
"//executorch/kernels/portable/cpu/pattern:all_deps",
"//executorch/runtime/kernel:kernel_includes",
"//executorch/kernels/portable/cpu:scalar_utils",
"//executorch/backends/cadence/hifi/kernels:kernels",
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
],
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
)


runtime.cxx_library(
name = "op_mul",
srcs = glob([
"op_mul.cpp",
]),
platforms = CXX,
deps = [
"//executorch/kernels/portable/cpu/util:all_deps",
"//executorch/kernels/portable/cpu/pattern:all_deps",
"//executorch/runtime/kernel:kernel_includes",
"//executorch/kernels/portable/cpu:scalar_utils",
"//executorch/backends/cadence/hifi/kernels:kernels",
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
],
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.cxx_library(
name = "op_sub",
srcs = glob([
"op_sub.cpp",
]),
platforms = CXX,
deps = [
"//executorch/kernels/portable/cpu/util:all_deps",
"//executorch/kernels/portable/cpu/pattern:all_deps",
"//executorch/runtime/kernel:kernel_includes",
"//executorch/kernels/portable/cpu:scalar_utils",
"//executorch/backends/cadence/hifi/kernels:kernels",
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
],
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.cxx_library(
name = "op_div",
srcs = glob([
"op_div.cpp",
]),
platforms = CXX,
deps = [
"//executorch/kernels/portable/cpu/util:all_deps",
"//executorch/kernels/portable/cpu/pattern:all_deps",
"//executorch/runtime/kernel:kernel_includes",
"//executorch/kernels/portable/cpu:scalar_utils",
"//executorch/backends/cadence/hifi/kernels:kernels",
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
],
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.cxx_library(
name = "op_sigmoid",
srcs = glob([
"op_sigmoid.cpp",
]),
platforms = CXX,
deps = [
"//executorch/kernels/portable/cpu/util:all_deps",
"//executorch/kernels/portable/cpu/pattern:all_deps",
"//executorch/runtime/kernel:kernel_includes",
"//executorch/backends/cadence/hifi/kernels:kernels",
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
],
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
)

runtime.cxx_library(
name = "op_tanh",
srcs = glob([
"op_tanh.cpp",
]),
platforms = CXX,
deps = [
"//executorch/kernels/portable/cpu/util:all_deps",
"//executorch/kernels/portable/cpu/pattern:all_deps",
"//executorch/runtime/kernel:kernel_includes",
"//executorch/backends/cadence/hifi/kernels:kernels",
"//executorch/backends/cadence/hifi/third-party/nnlib:nnlib-extensions"
],
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
)
5 changes: 5 additions & 0 deletions backends/cadence/hifi/third-party/nnlib/TARGETS
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
load("targets.bzl", "define_common_targets")

oncall("odai_jarvis")

define_common_targets()
18 changes: 18 additions & 0 deletions backends/cadence/hifi/third-party/nnlib/targets.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.

load("@fbsource//tools/build_defs:platform_defs.bzl", "CXX")
load("@fbsource//xplat/executorch/build:runtime_wrapper.bzl", "runtime")

def define_common_targets():
runtime.cxx_library(
name = "nnlib-extensions",
srcs = native.glob(["*.c", "*.cpp"]),
exported_headers = glob(["*.h"]),
visibility = [
"//executorch/backends/cadence/...",
"@EXECUTORCH_CLIENTS",
],
deps = [
"fbsource//third-party/nnlib-hifi4/xa_nnlib:libxa_nnlib",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include "xa_nnlib_err_chk.h"
#include "xa_nnlib_kernels_api.h"


#if HAVE_VFPU
static void internal_elm_add_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict__ p_out,
const FLOAT32 * __restrict__ p_inp1,
Expand Down Expand Up @@ -425,4 +424,3 @@ WORD32 xa_nn_elm_add_broadcast_4D_f32xf32_f32(FLOAT32 * __restrict__ p_out,
return 0;

}

Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ WORD32 xa_nn_elm_div_mode_f32xf32_f32(FLOAT32 * __restrict__ p_out,
XT_LASX2IP(x1, inp1_a, inp1);
XT_LASX2IP(x2, inp2_a, inp2);
y = XT_DIV_SX2(x1, x2);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SASX2IP(y, out_a, out);
}
}
Expand All @@ -66,7 +66,7 @@ WORD32 xa_nn_elm_div_mode_f32xf32_f32(FLOAT32 * __restrict__ p_out,
XT_LASX2IP(x1, inp1_a, inp1);
XT_LASX2IP(x2, inp2_a, inp2);
y = XT_DIV_SX2(x1, x2);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SASX2IP(y, out_a, out);
}
}
Expand All @@ -80,9 +80,9 @@ WORD32 xa_nn_elm_div_mode_f32xf32_f32(FLOAT32 * __restrict__ p_out,
XT_LSIP(a2, (xtfloat *)inp2, 0);
a = XT_DIV_S(a1, a2);
if(mode == 0)
a = FITRUNC_S(a);
a = XT_FITRUNC_S(a);
else
a = FIFLOOR_S(a);
a = XT_FIFLOOR_S(a);
XT_SSI(a, (xtfloat *)out, 0);
}

Expand Down Expand Up @@ -138,7 +138,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
XT_LSX2IP(x2, p_b, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x2, x1);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -149,7 +149,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
XT_LSX2IP(x2, p_b, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x2, x1);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -166,7 +166,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LASX2IP(x1, vinp1, p_a);
XT_LASX2IP(x2, vinp2, p_b);
y = XT_DIV_SX2(x2, x1);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -177,7 +177,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LASX2IP(x1, vinp1, p_a);
XT_LASX2IP(x2, vinp2, p_b);
y = XT_DIV_SX2(x2, x1);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -189,9 +189,9 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LSIP(b0, (xtfloat *)p_b, sizeof(FLOAT32));
c0 = XT_DIV_S(b0, a0);
if(mode == 0)
c0 = FITRUNC_S(c0);
c0 = XT_FITRUNC_S(c0);
else
c0 = FIFLOOR_S(c0);
c0 = XT_FIFLOOR_S(c0);
XT_SSI(c0, (xtfloat *)p_c, 0);
}
}
Expand All @@ -213,7 +213,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
XT_LSX2IP(x2, p_b, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x1, x2);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -224,7 +224,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
XT_LSX2IP(x2, p_b, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x1, x2);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -241,7 +241,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LASX2IP(x1, vinp1, p_a);
XT_LASX2IP(x2, vinp2, p_b);
y = XT_DIV_SX2(x1, x2);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -252,7 +252,7 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LASX2IP(x1, vinp1, p_a);
XT_LASX2IP(x2, vinp2, p_b);
y = XT_DIV_SX2(x1, x2);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -264,9 +264,9 @@ static void internal_elm_div_mode_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict_
XT_LSIP(b0, (xtfloat *)p_b, sizeof(FLOAT32));
c0 = XT_DIV_S(a0, b0);
if(mode == 0)
c0 = FITRUNC_S(c0);
c0 = XT_FITRUNC_S(c0);
else
c0 = FIFLOOR_S(c0);
c0 = XT_FIFLOOR_S(c0);
XT_SSI(c0, (xtfloat *)p_c, 0);
}
}
Expand Down Expand Up @@ -302,7 +302,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x2, x1);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -312,7 +312,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x2, x1);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -328,7 +328,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LASX2IP(x1, inp1_a, p_a);
y = XT_DIV_SX2(x2, x1);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -338,7 +338,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LASX2IP(x1, inp1_a, p_a);
y = XT_DIV_SX2(x2, x1);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -349,9 +349,9 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
XT_LSIP(a0_7, (xtfloat *)p_a, sizeof(FLOAT32));
out = XT_DIV_S(x2, a0_7);
if(mode == 0)
out = FITRUNC_S(out);
out = XT_FITRUNC_S(out);
else
out = FIFLOOR_S(out);
out = XT_FIFLOOR_S(out);
XT_SSI(out, (xtfloat *)p_c, 0);
}
}
Expand All @@ -366,7 +366,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x1, x2);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -376,7 +376,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LSX2IP(x1, p_a, 2 * sizeof(FLOAT32));
y = XT_DIV_SX2(x1, x2);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SSX2IP(y, p_c, 2 * sizeof(FLOAT32));
}
}
Expand All @@ -392,7 +392,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LASX2IP(x1, inp1_a, p_a);
y = XT_DIV_SX2(x1, x2);
y = FITRUNC_SX2(y);
y = XT_FITRUNC_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -402,7 +402,7 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
{
XT_LASX2IP(x1, inp1_a, p_a);
y = XT_DIV_SX2(x1, x2);
y = FIFLOOR_SX2(y);
y = XT_FIFLOOR_SX2(y);
XT_SASX2IP(y, out_a, p_c);
}
}
Expand All @@ -413,9 +413,9 @@ static void internal_elm_div_mode_broadcast_f32xf32_f32(FLOAT32 * __restrict__ p
XT_LSIP(a0_7, (xtfloat *)p_a, sizeof(FLOAT32));
out = XT_DIV_S(a0_7, x2);
if(mode == 0)
out = FITRUNC_S(out);
out = XT_FITRUNC_S(out);
else
out = FIFLOOR_S(out);
out = XT_FIFLOOR_S(out);
XT_SSI(out, (xtfloat *)p_c, 0);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,10 @@

******************************************************************************/
#include "xa_type_def.h"
#include "nnlib-hifi4/xa_nnlib/algo/common/include/xa_nnlib_common_fpu.h"
#include "nnlib-hifi4/xa_nnlib/algo/common/include/xa_nn_common.h"
#include "nnlib-hifi4/xa_nnlib/algo/common/include/xa_nnlib_err_chk.h"
#include "nnlib-hifi4/xa_nnlib/algo/kernels/basic/hifi4/xa_nn_basic_state.h"
#include "nnlib-hifi4/xa_nnlib/include/nnlib/xa_nnlib_kernels_api.h"
#include "xa_nnlib_common_fpu.h"
#include "xa_nn_common.h"
#include "xa_nnlib_err_chk.h"
#include "xa_nnlib_kernels_api.h"

#if HAVE_VFPU
static void internal_elm_mul_broadcast_2D_f32xf32_f32(FLOAT32 * __restrict__ p_out,
Expand Down
Loading