I hava look 모바일 및 Embedded TensorFlow (TensorFlow Dev Summit 2017) 비디오는 yotube에 있습니다. 여기 video link.OpKernel이 안드로이드에서이 attrs로 Op '추가'를 지원하도록 등록되지 않았습니다.
동영상에서 나는 tensorflow를 줄여서 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/코어/framework dir이고, selective_registration.h에서 SELECTIVE_REGISTRATION을 정의합니다. 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)]]