[PATCH] D119507: [MLGO] Use TFLite in 'development mode'
Petr Hosek via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 29 13:27:59 PDT 2022
phosek added a comment.
Herald added a project: All.
With the tip-of-tree TensorFlow, it should now be possible to use TFLite as a CMake package. I had to make the following changes to your patch:
diff --git a/llvm/CMakeLists.txt b/llvm/CMakeLists.txt
index 4ce0d9c21900..aa5fef9d1d18 100644
--- a/llvm/CMakeLists.txt
+++ b/llvm/CMakeLists.txt
@@ -861,23 +861,9 @@ include(AddLLVM)
# also leverage the dependency.
set(TENSORFLOW_SRC_DIR "" CACHE PATH "Path to TensorFlow source")
if (TENSORFLOW_SRC_DIR)
- set(TFLITE_ENABLE_XNNPACK OFF)
- # find_library(tflite_c tensorflowlite_c PATHS ${TENSORFLOW_SRC_DIR}/build NO_DEFAULT_PATH REQUIRED)
- # find_library(tflite tensorflow-lite PATHS ${TENSORFLOW_SRC_DIR}/build/tensorflow-lite NO_DEFAULT_PATH REQUIRED)
- # include_directories(${TENSORFLOW_SRC_DIR}/build/abseil-cpp)
- # include_directories(${TENSORFLOW_SRC_DIR}/build/eigen)
- # include_directories(${TENSORFLOW_SRC_DIR}/build/flatbuffers/include)
- message(STATUS "about to")
- set(LLVM_EXTERNAL_TFLITE_SOURCE_DIR "${TENSORFLOW_SRC_DIR}/tensorflow/lite")
- set(LLVM_TOOL_TFLITE_BUILD On)
- add_llvm_external_project(TFLITE)
- # install(TARGETS tensorflow-lite EXPORT LLVMExports
- # ARCHIVE DESTINATION lib${LLVM_LIBDIR_SUFFIX} COMPONENT tensorflow-lite)
- message(STATUS "done")
set(LLVM_HAVE_TF_API "ON" CACHE BOOL "Full Tensorflow API available")
- set(Protobuf_USE_STATIC_LIBS ON)
- find_package(Protobuf REQUIRED)
- include_directories(${Protobuf_INCLUDE_DIRS})
+ find_package(protobuf REQUIRED)
+ find_package(tensorflow-lite REQUIRED)
endif()
# For up-to-date instructions for installing the Tensorflow dependency, refer to
diff --git a/llvm/cmake/modules/TensorFlowCompile.cmake b/llvm/cmake/modules/TensorFlowCompile.cmake
index c1bb03db5e96..9d329cd3e81e 100644
--- a/llvm/cmake/modules/TensorFlowCompile.cmake
+++ b/llvm/cmake/modules/TensorFlowCompile.cmake
@@ -123,10 +123,10 @@ function(build_proto)
set(PBS ${PBS} ${TENSORFLOW_SRC_DIR}/${P}.proto)
endforeach()
add_custom_command(OUTPUT ${PB_SRCS} ${PB_HDRS}
- COMMAND ${PROTOBUF_PROTOC_EXECUTABLE} --proto_path=${TENSORFLOW_SRC_DIR}
- --cpp_out=${CMAKE_CURRENT_BINARY_DIR} ${PBS})
+ COMMAND protobuf::protoc
+ ARGS --proto_path=${TENSORFLOW_SRC_DIR} --cpp_out=${CMAKE_CURRENT_BINARY_DIR} ${PBS})
set_source_files_properties(${PB_SRCS} PROPERTIES
GENERATED 1)
set(GeneratedMLSources ${GeneratedMLSources} ${PB_SRCS} PARENT_SCOPE)
set(MLDeps ${MLDeps} ${GeneratedMLSources} PARENT_SCOPE)
-endfunction()
\ No newline at end of file
+endfunction()
diff --git a/llvm/lib/Analysis/CMakeLists.txt b/llvm/lib/Analysis/CMakeLists.txt
index 29a6bcda7dbd..6907cb2f3b58 100644
--- a/llvm/lib/Analysis/CMakeLists.txt
+++ b/llvm/lib/Analysis/CMakeLists.txt
@@ -25,15 +25,7 @@ if (DEFINED LLVM_HAVE_TF_AOT OR DEFINED LLVM_HAVE_TF_API)
tensorflow/core/protobuf/error_codes
tensorflow/core/example/feature
tensorflow/core/example/example)
- # list(APPEND MLLinkDeps ${tflite} ${tflite_c} ${Protobuf_LIBRARIES}
- # ${TENSORFLOW_SRC_DIR}/build/_deps/ruy-build/libruy.a
- # ${TENSORFLOW_SRC_DIR}/build/_deps/farmhash-build/libfarmhash.a
- # ${TENSORFLOW_SRC_DIR}/build/_deps/flatbuffers-build/libflatbuffers.a
- # ${TENSORFLOW_SRC_DIR}/build/_deps/fft2d-build/libfft2d_fftsg.a
- # ${TENSORFLOW_SRC_DIR}/build/_deps/fft2d-build/libfft2d_fftsg2d.a
- # )
- # include_directories(${TENSORFLOW_SRC_DIR})
- list(APPEND MLLinkDeps tensorflow-lite ${Protobuf_LIBRARIES})
+ list(APPEND MLLinkDeps tensorflow-lite::tensorflow-lite protobuf::libprotobuf)
endif()
endif()
diff --git a/llvm/lib/Analysis/TFUtils.cpp b/llvm/lib/Analysis/TFUtils.cpp
index fbaa47813ecb..24e86c9ca591 100644
--- a/llvm/lib/Analysis/TFUtils.cpp
+++ b/llvm/lib/Analysis/TFUtils.cpp
@@ -50,6 +50,7 @@ void serialize(const Message &SE, std::string *OutStr) {
*OutStr = SE.SerializeAsString();
}
}
+}
namespace llvm {
class EvaluationResultImpl {
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D119507/new/
https://reviews.llvm.org/D119507
More information about the llvm-commits
mailing list