Ошибка преобразования C ++ Tensorflow API в веб-сборку в Emscripten - PullRequest
0 голосов
/ 29 мая 2020

Я пытаюсь преобразовать сценарий C ++ в файл веб-сборки. Хотя я умею конвертировать любой плоский код на С ++. Но невозможно преобразовать, когда есть какая-либо зависимость библиотеки или файл заголовка из любой библиотеки фреймворка.

В настоящее время мой файл заголовка выглядит как

#include "tensorflow/cc/ops/const_op.h"
#include "tensorflow/cc/ops/image_ops.h"
#include "tensorflow/cc/ops/standard_ops.h"
#include "tensorflow/core/framework/graph.pb.h"
#include "tensorflow/core/framework/tensor.h"
#include "tensorflow/core/graph/default_device.h"
#include "tensorflow/core/graph/graph_def_builder.h"
#include "tensorflow/core/lib/core/errors.h"
#include "tensorflow/core/lib/core/stringpiece.h"
#include "tensorflow/core/lib/core/threadpool.h"
#include "tensorflow/core/lib/io/path.h"
#include "tensorflow/core/lib/strings/str_util.h"
#include "tensorflow/core/lib/strings/stringprintf.h"
#include "tensorflow/core/platform/init_main.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/types.h"
#include "tensorflow/core/public/session.h"
#include "tensorflow/core/util/command_line_flags.h"
#include <time.h>

// These are all common classes it's handy to reference with no namespace.
using tensorflow::Flag;
using tensorflow::Tensor;
using tensorflow::Status;
using tensorflow::string;
using tensorflow::int32;
using tensorflow::uint8;

И я перешел по этой ссылке, где Op столкнулся с подобной проблемой Скомпилировать программу WebAssembly, зависящую от внешних библиотек Opus и Faa c

И я придумал команду emscripten как

emcc \
   -o mainwithpoint.js \
   -s WASM=1 -s "MODULARIZE=1" -s "EXPORT_NAME='FLD'" \
  -s "BINARYEN_METHOD='native-wasm'" \
  -s "EXPORTED_FUNCTIONS=['_LoadGraph', '_ReadLabelsFile', '_ReadEntireFile', '_ReadTensorFromImageFile', '_Preprocess', '_SaveImage', '_main']" \
  -s EXTRA_EXPORTED_RUNTIME_METHODS='["ccall", "cwrap"]' \
  -I "/home/satya/tensorflow-r2.0/tensorflow/cc/ops/const_op.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/cc/ops/image_ops.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/cc/ops/image_ops.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/framework/graph.pb.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/framework/tensor.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/graph/default_device.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/graph/graph_def_builder.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/lib/core/errors.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/lib/core/stringpiece.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/lib/core/threadpool.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/lib/io/path.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/lib/strings/str_util.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/lib/strings/stringprintf.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/platform/init_main.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/platform/logging.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/platform/types.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/public/session.h" \
  -I "/home/satya/tensorflow-r2.0/tensorflow/core/util/command_line_flags.h" \
  mainwithpoint.cc

Фактически не было $ TENSORFLOW_DIR как такового для ВКЛЮЧЕНИЯ с опцией -I, поэтому я указал все фактические пути ко всем файлам заголовков.

Но это не срабатывает с ошибкой

     In file included from mainwithpoint.cc:14:
./tensorflow/cc/ops/const_op.h:19:10: fatal error: 'tensorflow/cc/framework/ops.h' file not found
#include "tensorflow/cc/framework/ops.h"
         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
emcc: error: '/home/satya/ems/emsdk/upstream/bin/clang++ -target wasm32-unknown-emscripten -D__EMSCRIPTEN_major__=1 -D__EMSCRIPTEN_minor__=39 -D__EMSCRIPTEN_tiny__=16 -D_LIBCPP_ABI_VERSION=2 -Dunix -D__unix -D__unix__ -Werror=implicit-function-declaration -Xclang -nostdsysteminc -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/include/libcxx -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/lib/libcxxabi/include -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/lib/libunwind/include -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/include/compat -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/include -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/include/libc -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/lib/libc/musl/arch/emscripten -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/local/include -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/cache/wasm/include -DEMSCRIPTEN -fignore-exceptions -I/home/satya/tensorflow-r2.0/tensorflow/cc/ops/const_op.h -I/home/satya/tensorflow-r2.0/tensorflow/cc/ops/image_ops.h -I/home/satya/tensorflow-r2.0/tensorflow/cc/ops/image_ops.h -I/home/satya/tensorflow-r2.0/tensorflow/core/framework/graph.pb.h -I/home/satya/tensorflow-r2.0/tensorflow/core/framework/tensor.h -I/home/satya/tensorflow-r2.0/tensorflow/core/graph/default_device.h -I/home/satya/tensorflow-r2.0/tensorflow/core/graph/graph_def_builder.h -I/home/satya/tensorflow-r2.0/tensorflow/core/lib/core/errors.h -I/home/satya/tensorflow-r2.0/tensorflow/core/lib/core/stringpiece.h -I/home/satya/tensorflow-r2.0/tensorflow/core/lib/core/threadpool.h -I/home/satya/tensorflow-r2.0/tensorflow/core/lib/io/path.h -I/home/satya/tensorflow-r2.0/tensorflow/core/lib/strings/str_util.h -I/home/satya/tensorflow-r2.0/tensorflow/core/lib/strings/stringprintf.h -I/home/satya/tensorflow-r2.0/tensorflow/core/platform/init_main.h -I/home/satya/tensorflow-r2.0/tensorflow/core/platform/logging.h -I/home/satya/tensorflow-r2.0/tensorflow/core/platform/types.h -I/home/satya/tensorflow-r2.0/tensorflow/core/public/session.h -I/home/satya/tensorflow-r2.0/tensorflow/core/util/command_line_flags.h mainwithpoint.cc -Xclang -isystem/home/satya/ems/emsdk/upstream/emscripten/system/include/SDL -c -o /tmp/emscripten_temp_gbwye3x_/mainwithpoint_0.o -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr' failed (1)

Это по-прежнему не удается найти файл заголовка. Я в основном парень из PYTHON и новичок в C ++, поэтому не могу его взломать. Кто-нибудь делал такую ​​Webassembly, любезно помогите мне. Это было бы очень полезно. Спасибо :)

...