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

No OpKernel was registered to support Op 'RFFT' for CPU (running on android) #11804

Closed
liuzqt opened this issue Jul 27, 2017 · 5 comments
Closed
Labels

Comments

@liuzqt
Copy link

liuzqt commented Jul 27, 2017

I'm running tensorflow on android. and got this error:
Caused by: java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'RFFT' with these attrs. Registered devices: [CPU], Registered kernels: <no registered kernels>

I'm using the master branch, where the RFFT CPU verison is already supported. So I'm wondering why this problem show up.

The TF version I used to build the graph(*.pb file) is also the latest master branch.
Here is to code I wrtie .pb graph:

    with tf.Graph().as_default(), tf.Session(config=tf.ConfigProto(
            allow_soft_placement=True)) as session:
        with tf.variable_scope("model"):
            model = DeployModel(config=config)

        print('Graph build finished')
        # variable_names = [n.name for n in
        #                   tf.get_default_graph().as_graph_def().node]
        # for n in variable_names:
        #     print(n)

        saver = tf.train.Saver()
        saver.restore(session, save_path=path_join(self.config.model_path,
                                                   'latest.ckpt'))
        print("model restored from %s" % config.model_path)

        frozen_graph_def = graph_util.convert_variables_to_constants(
            session, session.graph.as_graph_def(),
            ['model/inputX', 'model/softmax', 'model/nn_outputs'])
        tf.train.write_graph(
            frozen_graph_def,
            os.path.dirname(graph_path),
            os.path.basename(graph_path),
            as_text=False,
        )

So maybe RFFT for CPU is still not supported on android in the latest branch?

@liuzqt liuzqt changed the title No OpKernel was registered to support Op 'RFFT' with these attrs. No OpKernel was registered to support Op 'RFFT' for CPU (running on android) Jul 27, 2017
@aselle
Copy link
Contributor

aselle commented Jul 27, 2017

Android only builds a subset of the ops, You need to add the ops that you need that are not in the "commonly used set" by hacking the build files for your needs.

@aselle aselle added stat:awaiting response Status - Awaiting response from author type:build/install Build and install issues labels Jul 27, 2017
@andrewharp
Copy link
Contributor

@liuzqt You can follow @aselle's suggestion by adding fft_ops.cc to the //tensorflow/core/kernels:android_extended_ops_group1 filegroup and see if that solves the issue.

@liuzqt
Copy link
Author

liuzqt commented Jul 28, 2017

@andrewharp @aselle adding fft_ops.cc to build file solve the problem, many thanks! But it come up with a new problem, when running fft, raise this exception:
` Caused by: java.lang.IllegalArgumentException: No OpKernel was registered to support Op 'ComplexAbs' with these attrs. Registered devices: [CPU], Registered kernels:

                                                                 	 [[Node: model/fft = ComplexAbs[T=DT_COMPLEX64, Tout=DT_FLOAT, _device="/device:CPU:0"](model/rfft)]]
                                                                     at org.tensorflow.Session.run(Native Method)`

and then I refer to
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/kernels/cwise_op_abs.cc
found that
#if !defined(IS_MOBILE_PLATFORM) REGISTER2(UnaryOp, CPU, "ComplexAbs", functor::abs, complex64, complex128); #endif
so it means Complex2real is not supported on android?
If I want to implement this, how should I do? Can I just remove the "if !defined" to make this REGISTER compiled to android lib?

@aselle aselle removed the stat:awaiting response Status - Awaiting response from author label Jul 28, 2017
@aselle
Copy link
Contributor

aselle commented Jul 28, 2017

It seems like complexabs is not implemented. You could just try removing the #if !defined and see if it works. I'm not sure why that check was put in, but it is possible that it was for an old version that didn't support the complex type. @petewarden , any ideas?

@aselle aselle added stat:awaiting response Status - Awaiting response from author type:bug Bug and removed type:build/install Build and install issues labels Jul 28, 2017
@liuzqt
Copy link
Author

liuzqt commented Jul 30, 2017

@aselle I remove that #if !defined and it works! many thank!

@aselle aselle removed the stat:awaiting response Status - Awaiting response from author label Jul 31, 2017
rmlarsen pushed a commit that referenced this issue Apr 9, 2018
Seems like it was disabled long time ago before open-sourcing Tensorflow.
I think disabling it is no longer necessary.
Works now on Android. Could anyone check on iOS?

Somewhat related issue: #11804
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants