c++ - 简单 C++ TensorFlow Lite 测试程序的 Eigen 等问题

标签 c++ include-path eigen3 tensorflow-lite

我按照建议的步骤使用脚本 ${TENSORFLOW_ROOT}/tensorflow/lite/tools/make/build_rpi_lib.sh 为 TensorFlow Lite (r1.97) 的 C++ API 编译了库本官page ( native 编译,下载必要的库),其中 ${TENSORFLOW_ROOT} 是我克隆存储库的根文件夹。

我正在尝试编译这个简单的 test.cpp 程序:

#include <memory>

#include "tensorflow/lite/interpreter.h"

int main(void)
{
    std::unique_ptr<tflite::Interpreter> interpreter(new tflite::Interpreter);
}

使用命令:

gcc-6 test.cpp -I${TENSORFLOW_ROOT} -I${TENSORFLOW_ROOT}/tensorflow/contrib/makefile/downloads/eigen -I${TENSORFLOW_ROOT}/tensorflow/contrib/makefile/downloads/protobuf/src -I${TENSORFLOW_ROOT}/tensorflow/contrib/makefile/downloads -L${TENSORFLOW_ROOT}/tensorflow/lite/tools/make/gen/rpi_armv7l/lib -lstdc++ -ldl -ltensorflow-lite

包含列表在 Integrating TensorFlow libraries 中建议页面(特别是来自 iOS 部分)。编译失败,出现以下与包含 Eigen 相关的错误:

${TENSORFLOW_ROOT}/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42: fatal error: unsupported/Eigen/CXX11/Tensor: No such file or directory
 #include "unsupported/Eigen/CXX11/Tensor"

我发现了几个链接,其中讨论了一个明显相似的问题(例如这个 one ),但是建议的解决方案涉及使用对 TensorFlow python 包的引用,这在我的情况下是不可能的(而且感觉很patchy - 我不考虑在这个项目中使用 python。

我还尝试使用不同的 Eigen 包含路径(例如 ${TENSORFLOW_ROOT}/third_party/eigen3):

gcc-6 test.cpp -I${TENSORFLOW_ROOT} -I${TENSORFLOW_ROOT}/third_party/eigen3 -I${TENSORFLOW_ROOT}/tensorflow/contrib/makefile/downloads/protobuf/src -I${TENSORFLOW_ROOT}/tensorflow/contrib/makefile/downloads -L${TENSORFLOW_ROOT}/tensorflow/lite/tools/make/gen/rpi_armv7l/lib -lstdc++ -ldl -ltensorflow-lite

这也会导致与 Eigen 相关的此类编译错误:

...
${TENSORFLOW_ROOT}/third_party/eigen3/unsupported/Eigen/CXX11/Tensor:1:42: error: #include nested too deeply
 #include "unsupported/Eigen/CXX11/Tensor"
...
${TENSORFLOW_ROOT}/third_party/eigen3/Eigen/Core:1:22: error: #include nested too deeply
 #include "Eigen/Core"
...

关于如何解决这个问题有什么建议吗?正确的包含路径集是什么?

最佳答案

原来我放错了文件夹。而不是${TENSORFLOW_ROOT}/tensorflow/contrib/makefile/downloads/eigen${TENSORFLOW_ROOT}/third_party/eigen3,正确的是${TFLITE_ROOT }/tensorflow/lite/tools/make/downloads/eigen.

我仍然对存储库中 eigen 文件夹的数量感到困惑:

find . -name "eigen*" -type d                                                                                                                                             
./third_party/eigen3
./tensorflow/lite/tools/make/downloads/eigen

关于c++ - 简单 C++ TensorFlow Lite 测试程序的 Eigen 等问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54779775/

相关文章:

c++ - Visual Studio Code : C/C++: Multiple definitions for a header/include file shown; how to fix?

c++ - 一般产品中的特征自动类型推导

c++ - 如何使用 Eigen for B-Splines 处理噪声序列数据

c++ - 什么是适用于 Windows/C++ 的良好 2D 图形绘制 API?

c++ - SWIG 和 CMake : make use of information provided by `target_include_directories()`

c++ - visual studio 2010 包含目录路径

c++ - 为什么 Eigen 不解析内置符号? (所有,最后,seq,等等...)

c++ - Arduino以太网字节大小问题

c++ - 从基类指针集合中调用非虚拟成员函数?

c++ - 让我的 GTK 应用程序在 Linux 上启动时启动