miyosuda / TensorFlowAndroidMNIST

Tensorflow MNIST demo on Android
265 stars 108 forks source link

Building of tensorflow android libs #3

Open TianweiXing opened 8 years ago

TianweiXing commented 8 years ago

Hi, I 'm currently using "INV" op and encounter some error : Error during inference: Invalid argument: No OpKernel was registered to support Op 'Inv' with these attrs [[Node: incept5b/in4_conv1x1_55/batch_norm/moments/moments_1/divisor = Inv[T=DT_FLOAT](incept5b/in4_conv1x1_55/batch_norm/moments/moments/Const)]] I looked into tensorflow file, the "INV" register op should be in tensorflow/core/ops/math_ops.cc.

I think the tensorflow android libs don't include this op. I'm interested in how you build these .a and .lo libs? Could you build a lib that support the INV? Thanks

miyosuda commented 8 years ago

First I've built original TensorFlow android demo with bazel, and after that I extracted .lo and .a files from "bazel-out" dir. I've encountered similar error when I forgot to link "libandroid_tensorflow_kernels.lo" Are you linking this .lo file?

TianweiXing commented 8 years ago

@miyosuda Thanks for your response! I think this "libandroid_tensorflow_kernels.lo" is included, because I didn't change the settings here: https://github.com/miyosuda/TensorFlowAndroidMNIST/blob/master/jni-build/jni/Android.mk#L28 Is this what you mean for "link the "libandroid_tensorflow_kernels.lo" "? Thanks again!

miyosuda commented 8 years ago

@TianweiXing

Is this what you mean for "link the "libandroid_tensorflow_kernels.lo" "?

Yes

"libandroid_tensorflow_kernels" is defined here.

https://github.com/tensorflow/tensorflow/blob/r0.8/tensorflow/core/kernels/BUILD#L1557

And it uses "android_core_ops" and "android_extended_ops" rules. They seem to collect limited number of ops for android to keep the library small. For example,

https://github.com/tensorflow/tensorflow/blob/r0.8/tensorflow/core/kernels/BUILD#L1383-L1442

Could you take a look?

TianweiXing commented 8 years ago

@miyosuda Thanks a lot! I understand the structure now! And I solve the problem by adding the inverse op. It actually is included in tensorflow R0.9.

However, I met another error saying that:

06-06 15:26:10.871 16634-16634/jp.narr.tensorflowmnist E/native: tensorflow_jni.cc:262 Error during inference: Invalid argument: No OpKernel was registered to support Op 'Switch' with these attrs
                                                                      [[Node: incept5b/in4_conv1x1_55/batch_norm/cond/Switch = Switch[T=DT_BOOL](phase_train, phase_train)]]

But the switch op is in control_flow_ops.cc which is also included by android_extended_ops_group1.... So I really don't know how this error could happen...

By the way, do you know if there's any .io or .a file for tensorflow/core/framework/?

Thanks

beniroquai commented 7 years ago

Hey, this is an old one, but I'm trying to fulfill, what you've written above @miyosuda

I want to build the library for the TF 0.12 in the same way you've done that in your great app. I would really like to build the JNI-Files with NDK like you do in MNIST and also in this example. What exactly should I enter to build the DEMO app and what exactly do I need to extract from the build folder afterwards? I don't see any structure like you have in the jni-native folder (includes, *.lo files, etc.)

I'm a bit lost..Maybe you can help me and giving a quick hint? :) Thanks!

beniroquai commented 7 years ago

By the way..How do I find the files you put in the folder "include" ?

Is there any bazel rule which produces the entire output you've copied into /jni-build/jni? I'm a bit confused.