mirror of
https://github.com/bytecodealliance/wasm-micro-runtime.git
synced 2025-05-08 20:56:13 +00:00
Avoid re-installing if Tensorflow is already installed for WASI-NN (#2148)
Since the Tensorflow library is already installed in many cases(especially in the case of the embedded system), move the installation code to find_package.
This commit is contained in:
parent
c1723b8f3e
commit
ed6b8efade
|
@ -101,26 +101,6 @@ if (WAMR_BUILD_LIB_PTHREAD_SEMAPHORE EQUAL 1)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (WAMR_BUILD_WASI_NN EQUAL 1)
|
if (WAMR_BUILD_WASI_NN EQUAL 1)
|
||||||
if (NOT EXISTS "${WAMR_ROOT_DIR}/core/deps/tensorflow-src")
|
|
||||||
execute_process(COMMAND ${WAMR_ROOT_DIR}/core/deps/install_tensorflow.sh
|
|
||||||
RESULT_VARIABLE TENSORFLOW_RESULT
|
|
||||||
)
|
|
||||||
else ()
|
|
||||||
message("Tensorflow is already downloaded.")
|
|
||||||
endif()
|
|
||||||
set(TENSORFLOW_SOURCE_DIR "${WAMR_ROOT_DIR}/core/deps/tensorflow-src")
|
|
||||||
|
|
||||||
if (WASI_NN_ENABLE_GPU EQUAL 1)
|
|
||||||
# Tensorflow specific:
|
|
||||||
# * https://www.tensorflow.org/lite/guide/build_cmake#available_options_to_build_tensorflow_lite
|
|
||||||
set (TFLITE_ENABLE_GPU ON)
|
|
||||||
endif ()
|
|
||||||
|
|
||||||
include_directories (${CMAKE_CURRENT_BINARY_DIR}/flatbuffers/include)
|
|
||||||
include_directories (${TENSORFLOW_SOURCE_DIR})
|
|
||||||
add_subdirectory(
|
|
||||||
"${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
|
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL)
|
|
||||||
include (${IWASM_DIR}/libraries/wasi-nn/wasi_nn.cmake)
|
include (${IWASM_DIR}/libraries/wasi-nn/wasi_nn.cmake)
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
|
41
core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake
Normal file
41
core/iwasm/libraries/wasi-nn/cmake/Findtensorflow_lite.cmake
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||||
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
|
||||||
|
|
||||||
|
find_library(TENSORFLOW_LITE
|
||||||
|
NAMES tensorflow-lite
|
||||||
|
)
|
||||||
|
|
||||||
|
if(NOT EXISTS ${TENSORFLOW_LITE})
|
||||||
|
if (NOT EXISTS "${WAMR_ROOT_DIR}/core/deps/tensorflow-src")
|
||||||
|
execute_process(COMMAND ${WAMR_ROOT_DIR}/core/deps/install_tensorflow.sh
|
||||||
|
RESULT_VARIABLE TENSORFLOW_RESULT
|
||||||
|
)
|
||||||
|
else ()
|
||||||
|
message("Tensorflow is already downloaded.")
|
||||||
|
endif()
|
||||||
|
set(TENSORFLOW_SOURCE_DIR "${WAMR_ROOT_DIR}/core/deps/tensorflow-src")
|
||||||
|
|
||||||
|
if (WASI_NN_ENABLE_GPU EQUAL 1)
|
||||||
|
# Tensorflow specific:
|
||||||
|
# * https://www.tensorflow.org/lite/guide/build_cmake#available_options_to_build_tensorflow_lite
|
||||||
|
set (TFLITE_ENABLE_GPU ON)
|
||||||
|
endif ()
|
||||||
|
|
||||||
|
include_directories (${CMAKE_CURRENT_BINARY_DIR}/flatbuffers/include)
|
||||||
|
include_directories (${TENSORFLOW_SOURCE_DIR})
|
||||||
|
add_subdirectory(
|
||||||
|
"${TENSORFLOW_SOURCE_DIR}/tensorflow/lite"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/tensorflow-lite" EXCLUDE_FROM_ALL)
|
||||||
|
|
||||||
|
else()
|
||||||
|
find_path(TENSORFLOW_LITE_INCLUDE_DIR
|
||||||
|
NAMES tensorflow/lite/interpreter.h
|
||||||
|
)
|
||||||
|
find_path(FLATBUFFER_INCLUDE_DIR
|
||||||
|
NAMES flatbuffers/flatbuffers.h
|
||||||
|
)
|
||||||
|
include_directories (${TENSORFLOW_LITE_INCLUDE_DIR})
|
||||||
|
include_directories (${FLATBUFFER_INCLUDE_DIR})
|
||||||
|
endif()
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
# Copyright (C) 2019 Intel Corporation. All rights reserved.
|
||||||
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
||||||
|
|
||||||
|
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
|
||||||
|
|
||||||
|
# Find tensorflow-lite
|
||||||
|
find_package(tensorflow_lite REQUIRED)
|
||||||
|
|
||||||
set (WASI_NN_DIR ${CMAKE_CURRENT_LIST_DIR})
|
set (WASI_NN_DIR ${CMAKE_CURRENT_LIST_DIR})
|
||||||
|
|
||||||
include_directories (${WASI_NN_DIR})
|
include_directories (${WASI_NN_DIR})
|
||||||
|
|
Loading…
Reference in New Issue
Block a user