Skip to content

Commit b29e82d

Browse files
committed
fix i8mm
1 parent 2daa455 commit b29e82d

File tree

3 files changed

+30
-2
lines changed

3 files changed

+30
-2
lines changed

.github/workflows/linux-precompile.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ jobs:
1616
runs-on: ubuntu-20.04
1717
env:
1818
TFLITE_BEAM_PREFER_PRECOMPILED: NO
19+
TFBEAM_XNNPACK_ENABLE_ARM_I8MM: "OFF"
1920
name: Linux ${{ matrix.pair.target_arch }}-${{ matrix.pair.target_os }}-${{ matrix.pair.target_abi }} - OTP ${{ matrix.pair.otp }}
2021

2122
strategy:
@@ -116,7 +117,7 @@ jobs:
116117
cxx: "/usr/bin/riscv64-linux-gnu-g++"
117118

118119
steps:
119-
- uses: actions/checkout@v3
120+
- uses: actions/checkout@v4
120121

121122
- uses: erlef/setup-beam@v1
122123
with:

CMakeLists.txt

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,13 @@ if(DEFINED ENV{TARGET_ARCH})
6969
set(TFLITE_ENABLE_XNNPACK OFF CACHE BOOL "Disable XNNPACK in TensorFlow Lite for armv7l")
7070
elseif("$ENV{TARGET_ARCH}" MATCHES "arm")
7171
if(DEFINED ENV{TARGET_CPU})
72-
if("$ENV{TARGET_CPU}" STREQUAL "cortex_a53" OR "$ENV{TARGET_CPU}" STREQUAL "cortex_a57")
72+
if("$ENV{TARGET_CPU}" STREQUAL "cortex_a35" OR "$ENV{TARGET_CPU}" STREQUAL "cortex_a53" OR "$ENV{TARGET_CPU}" STREQUAL "cortex_a57" OR "$ENV{TARGET_CPU}" STREQUAL "cortex_a72" OR "$ENV{TARGET_CPU}" STREQUAL "cortex_a73")
7373
set(CMAKE_SYSTEM_PROCESSOR "armv8l" CACHE STRING "Updates CMAKE_SYSTEM_PROCESSOR")
74+
set(XNNPACK_ENABLE_ARM_FP16_SCALAR OFF CACHE BOOL "Disable XNNPACK fp16 scalar in TensorFlow Lite as it only available on armv8.2+")
75+
set(XNNPACK_ENABLE_ARM_FP16_VECTOR OFF CACHE BOOL "Disable XNNPACK fp16 vector in TensorFlow Lite as it only available on armv8.2+")
76+
set(XNNPACK_ENABLE_ARM_BF16 OFF CACHE BOOL "Disable XNNPACK bf16 in TensorFlow Lite as it only available on armv8.2+")
77+
set(XNNPACK_ENABLE_ARM_DOTPROD OFF CACHE BOOL "Disable XNNPACK dotprod in TensorFlow Lite as it only available on armv8.2+")
78+
set(XNNPACK_ENABLE_ARM_I8MM OFF CACHE BOOL "Disable XNNPACK i8mm in TensorFlow Lite as it only available on armv8.2+")
7479
elseif("$ENV{TARGET_CPU}" STREQUAL "cortex_a8" OR "$ENV{TARGET_CPU}" STREQUAL "cortex_a7")
7580
set(CMAKE_SYSTEM_PROCESSOR "armv7l" CACHE STRING "Updates CMAKE_SYSTEM_PROCESSOR")
7681
set(TFLITE_ENABLE_XNNPACK OFF CACHE BOOL "Disable XNNPACK in TensorFlow Lite for armv7l")
@@ -86,6 +91,22 @@ if(DEFINED ENV{TARGET_ARCH})
8691
endif()
8792
endif()
8893

94+
if(DEFINED ENV{TARGET_ARCH})
95+
if(NOT "$ENV{TARGET_ARCH}" STREQUAL "arm")
96+
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DTF_HAS_vcvtaq_s32_f32")
97+
endif()
98+
endif()
99+
100+
if(DEFINED ENV{TFBEAM_XNNPACK_ENABLE_ARM_I8MM})
101+
if("$ENV{TFBEAM_XNNPACK_ENABLE_ARM_I8MM}" STREQUAL "OFF")
102+
set(XNNPACK_ENABLE_ARM_I8MM OFF CACHE BOOL "Disable XNNPACK i8mm in TensorFlow Lite as TFBEAM_XNNPACK_ENABLE_ARM_I8MM is set to OFF")
103+
else()
104+
set(XNNPACK_ENABLE_ARM_I8MM ON CACHE BOOL "Enable XNNPACK i8mm in TensorFlow Lite as TFBEAM_XNNPACK_ENABLE_ARM_I8MM is set to ON")
105+
endif()
106+
else()
107+
set(XNNPACK_ENABLE_ARM_I8MM OFF CACHE BOOL "Disable XNNPACK i8mm in TensorFlow Lite as TFBEAM_XNNPACK_ENABLE_ARM_I8MM is default to OFF")
108+
endif()
109+
89110
if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
90111
if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 10.0)
91112
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-gnu-inline-cpp-without-extern")

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ bash "3rd_party/cache/${TFLITE_BEAM_CORAL_LIBEDGETPU_RUNTIME}/edgetpu_runtime/in
3636

3737
Defaults to `true`.
3838

39+
- `TFBEAM_XNNPACK_ENABLE_ARM_I8MM`
40+
41+
Set to 'ON' so that XNNPACK can use 8-bit Integer Matrix Multiply instructions. This also enables Advanced SIMD and floating-point instructions. Note that this only available on armv8.2-a and later.
42+
43+
Defaults to `OFF`.
44+
3945
- `TFLITE_BEAM_CORAL_SUPPORT`
4046

4147
Enable Coral Support.

0 commit comments

Comments
 (0)