I hava lookモバイルと埋め込みTensorFlow(TensorFlow Dev Summit 2017)のビデオはyotubeで、ここにはvideo linkです。OpKernelは登録されていません。これらのattrsをAndroidで使用するには、OpKernelは登録されていません。
ビデオでは、テンソルフローを減らしてファイルサイズをAndroid上で減らす機能を学びました。
が、私はここで行う* .pbファイルは自分自身をある
"""Prints a header file to be used with SELECTIVE_REGISTRATION.
Example usage:
print_selective_registration_header \
--graphs=path/to/graph.pb > ops_to_register.h
Then when compiling tensorflow, include ops_to_register.h in the include
search path and pass -DSELECTIVE_REGISTRATION - see
core/framework/selective_registration.h for more details.
"""
、その後、私はtensorflowにops_to_register.h入れ、ここ
#ifndef OPS_TO_REGISTER
#define OPS_TO_REGISTER
constexpr inline bool ShouldRegisterOp(const char op[]) {
return false
|| (strcmp(op, "Add") == 0)
|| (strcmp(op, "Const") == 0)
|| (strcmp(op, "Conv2D") == 0)
|| (strcmp(op, "Exp") == 0)
|| (strcmp(op, "Identity") == 0)
|| (strcmp(op, "Max") == 0)
|| (strcmp(op, "MaxPool") == 0)
|| (strcmp(op, "NoOp") == 0)
|| (strcmp(op, "Placeholder") == 0)
|| (strcmp(op, "RealDiv") == 0)
|| (strcmp(op, "Relu") == 0)
|| (strcmp(op, "Reshape") == 0)
|| (strcmp(op, "Sub") == 0)
|| (strcmp(op, "Sum") == 0)
|| (strcmp(op, "_Recv") == 0)
|| (strcmp(op, "_Send") == 0)
;
}
#define SHOULD_REGISTER_OP(op) ShouldRegisterOp(op)
const char kNecessaryOpKernelClasses[] = ","
"BinaryOp< CPUDevice, functor::add<float>>,"
"ConstantOp,"
"Conv2DOp<CPUDevice, float>,"
"UnaryOp< CPUDevice, functor::exp<float>>,"
"IdentityOp,"
"ReductionOp<CPUDevice, float, Eigen::internal::MaxReducer<float>>,"
"MaxPoolingOp<CPUDevice, float>,"
"NoOp,"
"PlaceholderOp,"
"BinaryOp< CPUDevice, functor::div<float>>,"
"ReluOp<CPUDevice, float>,"
"ReshapeOp,"
"BinaryOp< CPUDevice, functor::sub<float>>,"
"ReductionOp<CPUDevice, float, Eigen::internal::SumReducer<float>>,"
"RecvOp,"
"SendOp,"
;
#define SHOULD_REGISTER_OP_KERNEL(clz) (strstr(kNecessaryOpKernelClasses, "," clz ",") != nullptr)
#define SHOULD_REGISTER_OP_GRADIENT false
#endif
をops_to_register.hファイルを取得/ tensorflow /コア/フレームワークのdir、私はSELECTIVE_REGISTRATIONをselective_registration.hで定義します。
その後、私は私の.pbモデルを実行しますが、失敗した情報取得libtensorflow_inference.so使用し、Androidのプロジェクトで
bazel build -c opt //tensorflow/contrib/android:libtensorflow_inference.so --crosstool_top=//external:android/crosstool [email protected]_tools//tools/cpp:toolchain --cpu=armeabi-v7a --verbose_failures
を実行します。tesorflowブランチでいくつかの問題beacuseこのエラーを
native: tensorflow_inference_jni.cc:145 Could not create TensorFlow graph: Invalid argument: No OpKernel was registered to support Op 'Add' with these attrs. Registered devices: [CPU], Registered kernels:
<no registered kernels>
[[Node: add_1 = Add[T=DT_FLOAT](Conv2D, Reshape)]]