Skip to content

Commit 9a4d6ce

Browse files
Zonglin Pengfacebook-github-bot
authored andcommitted
fixed CPU kernel, unary_ufunc_realhbbf16_to_floathbf16, cpu flow (#5991)
Summary: kernel of cpu was not included. unary_ufunc_realhbbf16_to_floathbf16 was recently renamed cpu cmake was broken due to hifi change. need to move cpu cadence runner to 1 level up to include cadence kernel and ops. Pull Request resolved: #5991 Reviewed By: mcremon-meta Differential Revision: D64056710 Pulled By: zonglinpeng fbshipit-source-id: 91875312f657b78588a4e9212e02b57bf6408cad
1 parent a43b4a6 commit 9a4d6ce

File tree

7 files changed

+58
-88
lines changed

7 files changed

+58
-88
lines changed

CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ option(EXECUTORCH_BUILD_KERNELS_QUANTIZED "Build the quantized kernels" OFF)
201201

202202
option(EXECUTORCH_BUILD_DEVTOOLS "Build the ExecuTorch Developer Tools")
203203

204+
option(EXECUTORCH_NNLIB_OPT "Build Cadence backend Hifi nnlib kernel" OFF)
205+
206+
option(EXECUTORCH_CADENCE_CPU_RUNNER "Build Cadence backend CPU runner" OFF)
207+
204208
option(EXECUTORCH_BUILD_SIZE_TEST "Build the size test" OFF)
205209

206210
option(EXECUTORCH_BUILD_XNNPACK "Build the XNNPACK backend" OFF)

backends/cadence/CMakeLists.txt

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,54 @@ include(${EXECUTORCH_ROOT}/build/Utils.cmake)
2525
set(_common_include_directories ${EXECUTORCH_ROOT}/..)
2626
set(TARGET_DIR reference)
2727

28+
if(EXECUTORCH_CADENCE_CPU_RUNNER)
29+
include(${EXECUTORCH_ROOT}/build/Codegen.cmake)
30+
31+
if(NOT PYTHON_EXECUTABLE)
32+
resolve_python_executable()
33+
endif()
34+
35+
set(_common_compile_options -Wno-deprecated-declarations -fPIC)
36+
37+
# Find prebuilt libraries. executorch package should contain portable_ops_lib,
38+
# etdump, bundled_program.
39+
find_package(executorch CONFIG REQUIRED)
40+
target_link_options_shared_lib(executorch)
41+
target_link_options_shared_lib(portable_ops_lib)
42+
43+
target_include_directories(executorch INTERFACE ${_common_include_directories})
44+
45+
find_package(
46+
gflags REQUIRED PATHS ${CMAKE_CURRENT_BINARY_DIR}/../../third-party
47+
)
48+
49+
add_executable(cadence_runner
50+
${EXECUTORCH_ROOT}/examples/devtools/example_runner/example_runner.cpp
51+
)
52+
target_compile_options(executorch INTERFACE -DET_EVENT_TRACER_ENABLED)
53+
54+
target_include_directories(
55+
etdump INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/../../devtools/include
56+
${EXECUTORCH_ROOT}/third-party/flatcc/include
57+
)
58+
59+
target_include_directories(
60+
cadence_runner PUBLIC ${ROOT_DIR}/.. ${CMAKE_BINARY_DIR}
61+
${_common_include_directories}
62+
)
63+
64+
target_link_libraries(
65+
cadence_runner
66+
executorch
67+
gflags
68+
etdump
69+
extension_data_loader
70+
bundled_program
71+
cadence_ops_lib
72+
flatccrt
73+
)
74+
endif()
75+
2876
if(EXECUTORCH_NNLIB_OPT)
2977
set(TARGET_DIR hifi)
3078
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${TARGET_DIR}/third-party/nnlib)

backends/cadence/cadence_runner/build_cadence_runner.sh renamed to backends/cadence/build_cadence_runner.sh

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ set -euo pipefail
1212
SCRIPT_DIR="$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
1313
readonly SCRIPT_DIR
1414

15-
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../../.."
15+
readonly EXECUTORCH_ROOT="${SCRIPT_DIR}/../.."
1616

1717
# Allow overriding the number of build jobs. Default to 9.
1818
export CMAKE_BUILD_PARALLEL_LEVEL="${CMAKE_BUILD_PARALLEL_LEVEL:-9}"
@@ -25,15 +25,7 @@ main() {
2525
-DCMAKE_BUILD_TYPE=Release \
2626
-DEXECUTORCH_BUILD_DEVTOOLS=ON \
2727
-DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
28-
-DPYTHON_EXECUTABLE=python3 \
29-
-DEXECUTORCH_BUILD_EXTENSION_RUNNER_UTIL=ON \
30-
-DEXECUTORCH_BUILD_HOST_TARGETS=ON \
31-
-DEXECUTORCH_BUILD_EXECUTOR_RUNNER=OFF \
32-
-DEXECUTORCH_BUILD_PTHREADPOOL=OFF \
33-
-DEXECUTORCH_BUILD_CPUINFO=OFF \
34-
-DEXECUTORCH_ENABLE_LOGGING=ON \
35-
-DEXECUTORCH_NNLIB_OPT=OFF \
36-
-Bcmake-out
28+
-Bcmake-out .
3729
cmake --build cmake-out --target install --config Release -j16
3830

3931
local example_dir=backends/cadence
@@ -42,6 +34,7 @@ main() {
4234
rm -rf ${build_dir}
4335
cmake -DCMAKE_PREFIX_PATH="${cmake_prefix_path}" \
4436
-DCMAKE_BUILD_TYPE=Release \
37+
-DEXECUTORCH_CADENCE_CPU_RUNNER=ON \
4538
-B"${build_dir}" \
4639
"${example_dir}"
4740
cmake --build "${build_dir}" --config Release -j16

backends/cadence/cadence_runner/CMakeLists.txt

Lines changed: 0 additions & 74 deletions
This file was deleted.

backends/cadence/reference/kernels/kernels.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
* LICENSE file in the root directory of this source tree.
77
*/
88

9+
#include <executorch/backends/cadence/reference/kernels/kernels.h>
910
#include <math.h>
1011
#include <algorithm>
1112
#include <cstring>

backends/cadence/reference/operators/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ set(_aten_ops__srcs
3333
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/reduce_util.cpp"
3434
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/repeat_util.cpp"
3535
"${EXECUTORCH_ROOT}/kernels/portable/cpu/util/slice_util.cpp"
36-
"${EXECUTORCH_ROOT}/kernels/portable/cpu/pattern/unary_ufunc_realhb_to_floath.cpp"
36+
"${EXECUTORCH_ROOT}/kernels/portable/cpu/pattern/unary_ufunc_realhbbf16_to_floathbf16.cpp"
3737
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_bmm.cpp"
3838
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_cat.cpp"
3939
"${EXECUTORCH_ROOT}/kernels/portable/cpu/op_clone.cpp"

backends/cadence/runtime/executor.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,7 @@ def __init__(
106106
working_dir: str = "",
107107
):
108108
self.working_dir = working_dir
109-
self.executor_builder = (
110-
"./backends/cadence/cadence_runner/build_cadence_runner.sh"
111-
)
109+
self.executor_builder = "./backends/cadence/build_cadence_runner.sh"
112110
self.execute_runner = "./cmake-out/backends/cadence/cadence_runner"
113111
self.bundled_program_path: str = "CadenceDemoModel.bpte"
114112

0 commit comments

Comments
 (0)