1 # set target platform to run
2 if(NOT TARGET_ARCH OR "${TARGET_ARCH}" STREQUAL "")
3 string(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} TARGET_ARCH)
5 string(TOLOWER ${TARGET_ARCH} TARGET_ARCH)
8 # If TARGET_ARCH is arm64 change ARCH name to aarch64
9 if("${TARGET_ARCH}" STREQUAL "arm64")
10 set(TARGET_ARCH "aarch64")
13 if("${TARGET_ARCH}" STREQUAL "armv8-m")
14 set(TARGET_ARCH_BASE "arm")
15 elseif("${TARGET_ARCH}" STREQUAL "armv7-r")
16 set(TARGET_ARCH_BASE "arm")
17 elseif("${TARGET_ARCH}" STREQUAL "armv7em")
18 set(TARGET_ARCH_BASE "arm")
19 elseif("${TARGET_ARCH}" STREQUAL "armv7l")
20 set(TARGET_ARCH_BASE "arm")
21 elseif("${TARGET_ARCH}" STREQUAL "armv7hl")
22 set(TARGET_ARCH_BASE "arm")
23 elseif("${TARGET_ARCH}" STREQUAL "aarch64")
24 set(TARGET_ARCH_BASE "aarch64")
28 nnas_find_package(TensorFlowSource EXACT 2.8.0 QUIET)
29 nnas_find_package(TensorFlowGEMMLowpSource EXACT 2.8.0 QUIET)
30 nnas_find_package(TensorFlowEigenSource EXACT 2.8.0 QUIET)
31 nnas_find_package(TensorFlowRuySource EXACT 2.8.0 QUIET)
33 if (NOT TensorFlowSource_FOUND)
34 message(STATUS "Skipping luci-interpreter: TensorFlow not found")
38 if (NOT TensorFlowGEMMLowpSource_FOUND)
39 message(STATUS "Skipping luci-interpreter: gemmlowp not found")
43 if (NOT TensorFlowEigenSource_FOUND)
44 message(STATUS "Skipping luci-interpreter: Eigen not found")
48 if (NOT TensorFlowRuySource_FOUND)
49 message(STATUS "Skipping luci-interpreter: Ruy not found")
53 find_package(Threads REQUIRED)
55 set(PAL_INITIALIZED TRUE)
58 macro(add_pal_to_target TGT)
59 target_include_directories(${TGT} PRIVATE "${PAL}")
60 target_include_directories(${TGT} SYSTEM PRIVATE
61 "${TensorFlowRuySource_DIR}"
62 "${TensorFlowGEMMLowpSource_DIR}"
63 "${TensorFlowEigenSource_DIR}"
64 "${TensorFlowSource_DIR}")
65 target_include_directories(${TGT} PRIVATE ${LUCI_INTERPRETER_PAL_DIR})
67 # TODO put it back, I changed my mind.
68 # instead add sources with visitors in this library
69 set(PAL_SOURCES ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/tensor_utils.cc
70 ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/reference/portable_tensor_utils.cc
71 ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/quantization_util.cc)
73 if(TARGET_ARCH_BASE STREQUAL "arm")
74 # NOTE may need to revise this list for version upgrade
75 set(PAL_SOURCES ${PAL_SOURCES}
76 ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/optimized/neon_tensor_utils.cc
77 ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/optimized/cpu_check.cc
78 ${TensorFlowRuySource_DIR}/ruy/allocator.cc
79 ${TensorFlowRuySource_DIR}/ruy/block_map.cc
80 ${TensorFlowRuySource_DIR}/ruy/blocking_counter.cc
81 ${TensorFlowRuySource_DIR}/ruy/context_get_ctx.cc
82 ${TensorFlowRuySource_DIR}/ruy/cpuinfo.cc
83 ${TensorFlowRuySource_DIR}/ruy/ctx.cc
84 ${TensorFlowRuySource_DIR}/ruy/denormal.cc
85 ${TensorFlowRuySource_DIR}/ruy/frontend.cc
86 ${TensorFlowRuySource_DIR}/ruy/pack_arm.cc
87 ${TensorFlowRuySource_DIR}/ruy/prepacked_cache.cc
88 ${TensorFlowRuySource_DIR}/ruy/prepare_packed_matrices.cc
89 ${TensorFlowRuySource_DIR}/ruy/system_aligned_alloc.cc
90 ${TensorFlowRuySource_DIR}/ruy/thread_pool.cc
91 ${TensorFlowRuySource_DIR}/ruy/trmul.cc
92 ${TensorFlowRuySource_DIR}/ruy/tune.cc
93 ${TensorFlowRuySource_DIR}/ruy/wait.cc
94 ${TensorFlowRuySource_DIR}/ruy/kernel_arm32.cc
96 endif(TARGET_ARCH_BASE STREQUAL "arm")
98 if(TARGET_ARCH_BASE STREQUAL "aarch64")
99 # NOTE may need to revise this list for version upgrade
100 set(PAL_SOURCES ${PAL_SOURCES}
101 ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/optimized/neon_tensor_utils.cc
102 ${TensorFlowSource_DIR}/tensorflow/lite/kernels/internal/optimized/cpu_check.cc
103 ${TensorFlowRuySource_DIR}/ruy/allocator.cc
104 ${TensorFlowRuySource_DIR}/ruy/block_map.cc
105 ${TensorFlowRuySource_DIR}/ruy/blocking_counter.cc
106 ${TensorFlowRuySource_DIR}/ruy/context_get_ctx.cc
107 ${TensorFlowRuySource_DIR}/ruy/cpuinfo.cc
108 ${TensorFlowRuySource_DIR}/ruy/ctx.cc
109 ${TensorFlowRuySource_DIR}/ruy/denormal.cc
110 ${TensorFlowRuySource_DIR}/ruy/frontend.cc
111 ${TensorFlowRuySource_DIR}/ruy/pack_arm.cc
112 ${TensorFlowRuySource_DIR}/ruy/prepacked_cache.cc
113 ${TensorFlowRuySource_DIR}/ruy/prepare_packed_matrices.cc
114 ${TensorFlowRuySource_DIR}/ruy/system_aligned_alloc.cc
115 ${TensorFlowRuySource_DIR}/ruy/thread_pool.cc
116 ${TensorFlowRuySource_DIR}/ruy/trmul.cc
117 ${TensorFlowRuySource_DIR}/ruy/tune.cc
118 ${TensorFlowRuySource_DIR}/ruy/wait.cc
119 ${TensorFlowRuySource_DIR}/ruy/kernel_arm64.cc
121 endif(TARGET_ARCH_BASE STREQUAL "aarch64")
123 add_library(luci_interpreter_linux_pal STATIC ${PAL_SOURCES})
124 set_target_properties(luci_interpreter_linux_pal PROPERTIES POSITION_INDEPENDENT_CODE ON)
125 target_include_directories(luci_interpreter_linux_pal SYSTEM PRIVATE
126 "${TensorFlowRuySource_DIR}"
127 "${TensorFlowGEMMLowpSource_DIR}"
128 "${TensorFlowEigenSource_DIR}"
129 "${TensorFlowSource_DIR}"
132 target_link_libraries(${TGT} PRIVATE Threads::Threads luci_interpreter_linux_pal)