Skip to content

Commit 2e5dc27

Browse files
authored
[NNAdapter][AndroidNNAPI] Init support for Android NNAPI (#8390)
1 parent 1d46372 commit 2e5dc27

62 files changed

Lines changed: 5799 additions & 136 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmake/configure.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,9 @@ if (LITE_WITH_NNADAPTER)
238238
if (NNADAPTER_WITH_KUNLUNXIN_XTCL)
239239
add_definitions("-DNNADAPTER_WITH_KUNLUNXIN_XTCL")
240240
endif()
241+
if (NNADAPTER_WITH_ANDROID_NNAPI)
242+
add_definitions("-DNNADAPTER_WITH_ANDROID_NNAPI")
243+
endif()
241244
endif()
242245
endif()
243246

lite/backends/nnadapter/nnadapter/driver/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,7 @@ endif()
4949
if(NNADAPTER_WITH_KUNLUNXIN_XTCL)
5050
add_subdirectory(kunlunxin_xtcl)
5151
endif()
52+
53+
if(NNADAPTER_WITH_ANDROID_NNAPI)
54+
add_subdirectory(android_nnapi)
55+
endif()
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
set(DEVICE_NAME android_nnapi)
16+
add_definitions(-DNNADAPTER_DEVICE_NAME=${DEVICE_NAME})
17+
add_definitions(-DNNADAPTER_DEVICE_SYMBOL=${NNADAPTER_DEVICE_SYMBOL_PREFIX}${DEVICE_NAME})
18+
19+
include(dependencies.cmake)
20+
21+
aux_source_directory(converter CONVERTERS)
22+
aux_source_directory(optimizer OPTIMIZERS)
23+
set(SRCS nnapi_implementation.cc utility.cc ${OPTIMIZERS} ${CONVERTERS} engine.cc driver.cc)
24+
set(DEPS ${NNADAPTER_CORE} ${NNADAPTER_UTILITIES} nnadapter_optimizer_symm2asymm nnadapter_optimizer_nchw2nhwc nnadapter_optimizer_fuse_matmul_add_into_fully_connected ${${DEVICE_NAME}_deps})
25+
26+
add_library(${DEVICE_NAME} SHARED ${SRCS})
27+
target_link_libraries(${DEVICE_NAME} "-Wl,--start-group" ${DEPS} "-Wl,--end-group")
28+
set(NNADAPTER_DEVICES ${NNADAPTER_DEVICES} ${DEVICE_NAME} CACHE INTERNAL "")

0 commit comments

Comments
 (0)