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
13 changes: 13 additions & 0 deletions backends/cadence/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,19 @@ if(EXECUTORCH_NNLIB_OPT)
${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels)
elseif(
EXECUTORCH_HIFI_CORE STREQUAL "hifi1"
OR EXECUTORCH_HIFI_CORE STREQUAL "hifi4"
OR EXECUTORCH_HIFI_CORE STREQUAL "hifi5"
)
if(EXECUTORCH_HIFI_CORE STREQUAL "hifi5")
add_compile_definitions(CORE_HIFI5=1)
else()
add_compile_definitions(CORE_HIFI5=0)
endif()
set(TARGET_DIR hifi)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/kernels)
elseif(EXECUTORCH_FUSION_G3_OPT)
set(TARGET_DIR fusion_g3)
add_subdirectory(
Expand Down
4 changes: 2 additions & 2 deletions backends/cadence/cadence.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ set(CMAKE_C_COMPILER ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-clang)
set(CMAKE_CXX_COMPILER ${TOOLCHAIN_HOME}/bin/${CROSS_COMPILE_TARGET}-clang++)

set(CMAKE_C_FLAGS_INIT
"-stdlib=libc++ -mtext-section-literals -mlongcalls -DET_ENABLE_ENUM_STRINGS=0"
"-stdlib=libc++ -mtext-section-literals -mlongcalls -DET_ENABLE_ENUM_STRINGS=0 -O3 -mcoproc -LNO:simd -ffunction-sections -fsigned-char -INLINE:requested -fno-zero-initialized-in-bss -fmessage-length=0"
)
set(CMAKE_CXX_FLAGS_INIT
"-stdlib=libc++ -mtext-section-literals -mlongcalls -DET_ENABLE_ENUM_STRINGS=0"
"-stdlib=libc++ -mtext-section-literals -mlongcalls -DET_ENABLE_ENUM_STRINGS=0 -O3 -mcoproc -LNO:simd -ffunction-sections -fsigned-char -INLINE:requested -fno-zero-initialized-in-bss -fmessage-length=0"
)
# workaround for larger compilation time
set(CMAKE_CXX_FLAGS_INIT "${CMAKE_CXX_FLAGS_INIT} -fno-strict-aliasing")
Expand Down
16 changes: 12 additions & 4 deletions backends/cadence/hifi/kernels/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,22 @@ set(_common_include_directories
${EXECUTORCH_ROOT}/.. ${EXECUTORCH_ROOT}/runtime/core/portable_type/c10
)

if(EXECUTORCH_HIFI_CORE STREQUAL "hifi5")
set(NNLIB_DIR_NAME "nnlib-hifi5")
set(NNLIB_ARCH_DIR "hifi5")
else()
set(NNLIB_DIR_NAME "nnlib-hifi4")
set(NNLIB_ARCH_DIR "hifi4")
endif()

target_include_directories(
cadence_kernels
PUBLIC
.
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/algo/common/include/
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/include/nnlib
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/include
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/algo/ndsp/hifi4/include/
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/${NNLIB_DIR_NAME}/xa_nnlib/algo/common/include/
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/${NNLIB_DIR_NAME}/xa_nnlib/include/nnlib
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/${NNLIB_DIR_NAME}/xa_nnlib/include
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/${NNLIB_DIR_NAME}/xa_nnlib/algo/ndsp/${NNLIB_ARCH_DIR}/include/
${_common_include_directories}
)

Expand Down
5 changes: 5 additions & 0 deletions backends/cadence/hifi/kernels/kernels.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,12 @@

#include <executorch/backends/cadence/hifi/kernels/kernels.h>
#include <xa_nnlib_common.h>

#if CORE_HIFI5
#include <xa_nnlib_common_macros_hifi5.h>
#else
#include <xa_nnlib_common_macros.h>
#endif

namespace impl {
namespace HiFi {
Expand Down
8 changes: 7 additions & 1 deletion backends/cadence/hifi/third-party/nnlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
cmake_minimum_required(VERSION 3.10.0)
project(cadence_nnlib)

if(EXECUTORCH_HIFI_CORE STREQUAL "hifi5")
set(NNLIB_DIR_NAME "nnlib-hifi5")
else()
set(NNLIB_DIR_NAME "nnlib-hifi4")
endif()

add_custom_target(
nnlib_target ALL
COMMAND
make install_nnlib -f makefile -C
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/nnlib-hifi4/xa_nnlib/build
${EXECUTORCH_ROOT}/backends/cadence/hifi/third-party/nnlib/${NNLIB_DIR_NAME}/xa_nnlib/build
OBJDIR=${CMAKE_CURRENT_BINARY_DIR}/obj
LIBDIR=${CMAKE_CURRENT_BINARY_DIR}/lib -j8
)
Expand Down
6 changes: 5 additions & 1 deletion backends/cadence/hifi/third-party/nnlib/xa_nn_reduce_32_32.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
#include "xa_nnlib_common.h"
#include <string.h>
//#include "xa_nn_basic_state.h"
#include "xa_nnlib_common_macros.h"
#if CORE_HIFI5
#include <xa_nnlib_common_macros_hifi5.h>
#else
#include <xa_nnlib_common_macros.h>
#endif

#define ALIGNMENT_8 8

Expand Down
27 changes: 15 additions & 12 deletions backends/cadence/install_requirements.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,28 +10,31 @@ green=`tput setaf 2`

EXECUTORCH_ROOT_PATH=$(realpath "$SCRIPT_DIR_PATH/../../")
CADENCE_DIR_PATH="$EXECUTORCH_ROOT_PATH/backends/cadence"
HIFI_DIR_PATH="$CADENCE_DIR_PATH/hifi/third-party/nnlib/nnlib-hifi4"
FUSION_DIR_PATH="$CADENCE_DIR_PATH/fusion_g3/third-party/nnlib/nnlib-FusionG3"
FACTO_DIR_PATH="$CADENCE_DIR_PATH/utils/FACTO"

cd "$EXECUTORCH_ROOT_PATH"

## HiFi

rm -rf "$HIFI_DIR_PATH"
mkdir -p "$HIFI_DIR_PATH"
targets=(hifi4 hifi5)

echo "${green}ExecuTorch: Cloning hifi nnlib"
git clone "https://github.com/foss-xtensa/nnlib-hifi4.git" $HIFI_DIR_PATH
cd $HIFI_DIR_PATH
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "${red}ExecuTorch: Failed to clone hifi nnlib."
exit 1
fi
for target in ${targets[@]};
do
TARGET_DIR_PATH="$CADENCE_DIR_PATH/hifi/third-party/nnlib/nnlib-$target"

git checkout 64d73d729797388b0e346794d7a2e408374a74de
rm -rf "$TARGET_DIR_PATH"
mkdir -p "$TARGET_DIR_PATH"

echo "${green}ExecuTorch: Cloning $target nnlib"
git clone "https://github.com/foss-xtensa/nnlib-$target.git" $TARGET_DIR_PATH
cd $TARGET_DIR_PATH
STATUS=$?
if [ $STATUS -ne 0 ]; then
echo "${red}ExecuTorch: Failed to clone $target nnlib."
exit 1
fi
done

## Fusion G3

Expand Down
Loading