Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android - No OpKernel was registered to support Op 'Cos' with these attrs. Registered devices: [CPU], Registered kernels: <no registered kernels> [[Node: stft/hann_window/Cos = Cos[T=DT_FLOAT, _device="/device:CPU:0"](stft/hann_window/truediv)]] #14158

Closed
eli99999 opened this issue Nov 1, 2017 · 6 comments
Labels
type:support Support issues

Comments

@eli99999
Copy link

eli99999 commented Nov 1, 2017

I've exported a model to Android that uses :
stfts = tf.contrib.signal.stft(transwav, frame_length=2048, frame_step=512,
fft_length=2048,window_fn=functools.partial(tf.contrib.signal.hann_window, periodic=False), pad_end=True)
the model works properly in pyhton
but when i load it in Android using the downloaded compiled tensorflow - compile 'org.tensorflow:tensorflow-android:+'
I get this error -
FATAL EXCEPTION: main
Process: org.tensorflow.demo, PID: 25836
java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'Cos' with these attrs. Registered devices: [CPU], Registered kernels:
[[Node: stft/hann_window/Cos = CosT=DT_FLOAT, _device="/device:CPU:0"]]

which comes from the hann_window

any recommended work around?

@jart jart added the type:support Support issues label Nov 1, 2017
@jart
Copy link
Contributor

jart commented Nov 1, 2017

This is a very common issue with Android development. You need to make sure all the kernels you need are in your build. Please check StackOverflow and search Google for similar issues.

@jart jart closed this as completed Nov 1, 2017
@jart
Copy link
Contributor

jart commented Nov 1, 2017

Please note that C++ kernels use a registration pattern.

@eli99999
Copy link
Author

eli99999 commented Nov 2, 2017

I have recompiled libtensorflow_inference.so with print_selective_registration_header
and i see in the ops_to_register.h file the Cos OP -

...
constexpr inline bool ShouldRegisterOp(const char op[]) {
return false
|| isequal(op, "Add")
|| isequal(op, "BatchToSpaceND")
|| isequal(op, "CTCBeamSearchDecoder")
|| isequal(op, "Cast")
|| isequal(op, "Complex")
|| isequal(op, "ComplexAbs")
|| isequal(op, "ConcatV2")
|| isequal(op, "Const")
|| isequal(op, "Conv2D")
|| isequal(op, "Cos")
|| isequal(op, "DecodeWav")
|| isequal(op, "Exp")
|| isequal(op, "ExpandDims")
|| isequal(op, "Fill")...
there for it should be compiled into the libtensorflow_inference.so

but i still get the same error message when trying to run the model in my android app

@bobeo
Copy link

bobeo commented Nov 3, 2017

@eli99999 Please let me know if this help.

@eli99999
Copy link
Author

eli99999 commented Nov 5, 2017

@bobeo thanks,
I looked into it, and it seems that there is a problem with the bazel compilation
i changed the models a few time and then did the ops_to_register.h process,
each time the ops_to_register.h file changed but the libtensorflow_inference.so does not.
I tried all sort of bazel clean and bazel dump, and not chaned the resulted libtensorflow_inference.so
so i think that either there is some issue with the bazel caching or that the bug is in the print_selective_registration_header process

i'm working on ubuntu 16.04
bazel 0.7.0
tf 1.4

@naktinis
Copy link

naktinis commented Mar 6, 2018

I've answered a similar question on StackOverflow: https://stackoverflow.com/questions/49116833/no-opkernel-was-registered-to-support-op-cos-when-running-inference-on-android

Apparently, you might need to "hack" the BUILD file, according to one of the TensorFlow developers: #11804 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type:support Support issues
Projects
None yet
Development

No branches or pull requests

4 participants