【问题标题】:Compiling the tensorflow lite minimal example编译 tensorflow lite 最小示例
【发布时间】:2018-11-08 19:00:45
【问题描述】:

我正在尝试在 android 上使用 tensorflow lite。使用 android studio 编译时出现错误:

undefined reference to 'tflite::InterpreterBuilder::operator()(std::__ndk1::unique_ptr<tflite::Interpreter, std::__ndk1::default_delete<tflite::Interpreter> >*)'

在尝试编译 this minimal example from the tf repo 时,我设法获得了一个可重现的示例。

获取错误的步骤

  1. 下载android ndk(15c和16b我都试过了,都失败了)。拨打build/tools/make_standalone_toolchain.py --arch arm --api 21 --stl=libc++ --install-dir android-toolchain

  2. 构建 libtensorflow,这是在我的构建文件中。

tensorflow/lite/BUILD

cc_binary(
    name = "libtensorflowlite.so",
    linkopts=[
        "-shared",
        "-Wl,-soname=libtensorflowlite.so",
    ],  
    linkshared = 1,
    copts = tflite_copts(),
    deps = [ 
        ":framework",
        "//tensorflow/lite/kernels:builtin_ops",
    ],  
)

我这样称呼它:

bazel build //tensorflow/lite:libtensorflowlite.so --crosstool_top=//external:android/crosstool --cpu=armeabi-v7a --host_crosstool_top=@bazel_tools//tools/cpp:toolchain --cxxopt="-std=c++11"
  1. 我克隆 flatbuffer 存储库(一个依赖项)并编译它。

  2. 然后我尝试编译minimal.cc

我这样称呼它:

android-toolchain/bin/clang++  -std=c++11 -Igit/tensorflow-android -Igit/flatbuffers/include -Lgit/tensorflow-android -Lgit/flatbuffers/build minimal.cc -ltensorflowlite -lflatbuffers

libtensorflow.sogit/tensorflow-androidlibflatbuffers.agit/flatbuffers/build

发生了什么事?我不知道为什么要调用这个方法,我不是用两个参数调用对象。

【问题讨论】:

    标签: android tensorflow tensorflow-lite


    【解决方案1】:

    错误是我没有使用 ndk 18。我没有切换到它,因为编译 bazel 时特别告诉我使用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-06-29
      • 1970-01-01
      • 2019-11-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-08-01
      • 1970-01-01
      相关资源
      最近更新 更多