Skip to content

tfcompile with tf.nn.dynamic_rnn crashes #11275

Closed

Description

@carlthome

Trying to build a C++ binary with tfcompile crashes with INVALID ARGUMENTS: Mising Exit successor to rnn/while/Switch if the graph contains tf.nn.dynamic_rnn, but it works with tf.nn.static_rnn. Why is this?

Activity

  1. drpngx commented on Jul 4, 2017

    @drpngx
    Contributor

    @tatatodd any idea?

  2. tatatodd commented on Jul 6, 2017

    @tatatodd
    Contributor

    @carlthome What version of tensorflow are you using? Since XLA and tfcompile support is currently experimental, I'll suggest you build from sources at HEAD.

    Also, can you provide a minimal test case that demonstrates the problem? Thanks!

  3. added
    stat:awaiting response
    on Jul 6, 2017
  4. patrikohlsson commented on Jul 7, 2017

    @patrikohlsson

    I'm having the same issue with tfcompile and tf.nn.dynamic_rnn.

    OS:
    Ubuntu 16.04
    TF version:
    1.2.1 built from source without GPU support and no XLA JIT.

    Test case:

    xin = tf.placeholder(tf.float32, [1, 10, 10], name='input')
    cell = tf.contrib.rnn.LSTMCell(512)
    out, _ = tf.nn.dynamic_rnn(cell, xin, dtype=tf.float32)
    out = tf.identity(out, name='output')
    
    sess = tf.Session()
    sess.run(tf.global_variables_initializer())
    
    saver = tf.train.Saver()
    saver.save(sess, 'outgraph')

    outgraph.config.pbtxt:

    feed {
      id {
        node_name: "input"
      }
      shape {
        dim { size: 1 }
        dim { size: 10 }
        dim { size: 10 }
      }
    }
    
    fetch {
      id {
        node_name: "output"
      }
    }
    

    BUILD file:

    load("//tensorflow/compiler/aot:tfcompile.bzl", "tf_library")
    
    tf_library(
      name = "test_dyn_rnn",
      cpp_class = "TestDynRNN",
      graph = "outgraph.pb",
      config = "outgraph.config.pbtxt",
      freeze_checkpoint = "outgraph.ckpt"
    )

    Command:
    bazel build //tensorflow/compiler/aot/tests/test_dyn_rnn:test_dyn_rnn

    The build command results in INVALID ARGUMENTS: Missing Exit successor to encoder/rnn/while/Switch.
    Swapping to tf.nn.static_rnn works however.

    Here's a complete example.

  5. carlthome commented on Jul 11, 2017

    @carlthome
    ContributorAuthor

    I've been able to consistently reproduce the error INVALID ARGUMENTS: Missing Exit successor to rnn/while/Switch with master, thanks to @patrikohlsson's example. Perhaps @ebrevdo has some insight into what makes tf.nn.dynamic_rnn finicky with tfcompile?

  6. removed
    stat:awaiting response
    on Jul 12, 2017
  7. patrikohlsson commented on Jul 13, 2017

    @patrikohlsson

    With the XLA JIT fix posted by kayzhu in #11122 I can now reproduce the Missing Exit successor with XLA JIT enabled as well.

  8. tatatodd commented on Jul 13, 2017

    @tatatodd
    Contributor

    The tf.nn.dynamic_rnn library uses TensorFlow control-flow, which isn't well supported by XLA. There's a little bit of special support in the JIT codepath, but the AOT (i.e. tfcompile) codepath doesn't support this at all right now.

    Errors about Enter, Exit, Switch and Merge nodes are all symptoms of of this problem.

    There is no workaround at the moment. There are some in-process discussions and prototyping about how to handle this. Our exact approach hasn't been fleshed out yet.

    @hawkinsp may have some more details.

  9. carlthome commented on Jul 13, 2017

    @carlthome
    ContributorAuthor

    Cool. It would be nice if XLA AOT supported loops eventually. Is there a list in the documentation about what ops are not well supported at the moment? Particularly, the tf.nn stuff I'd expect to work as it's a core package.

    For my particular use case with a recurrent neural network (RNN), it's fine to unroll it manually before tfcompile and pad/truncate test data as needed, but I'd imagine there are applications where that fix would not be straightforward.

  10. tatatodd commented on Jul 13, 2017

    @tatatodd
    Contributor

    @carlthome Yeah, one way or another we'll have support for loops in XLA AOT; we just need to work out the technical details.

    We don't have documentation about what TensorFlow ops we support via XLA AOT or JIT at the moment, but the implementation of all of the TF->XLA translations is here:
    https://github.com/tensorflow/tensorflow/tree/master/tensorflow/compiler/tf2xla/kernels

    And yes, thanks for mentioning unrolling. Indeed for some models, a workaround is to statically unroll your loops before feeding into XLA. An example for LSTMs is here:
    https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/tests/lstm.py
    https://github.com/tensorflow/tensorflow/blob/master/tensorflow/compiler/tests/lstm_test.py

  11. ebrevdo commented on Jul 13, 2017

    @ebrevdo
    Contributor
  12. jart commented on Jul 13, 2017

    @jart
    Contributor

    @tatatodd I'm assigning to you to take out of triage queue. Feel free to re-assign

  13. carlthome commented on Sep 19, 2017

    @carlthome
    ContributorAuthor

    ETA on tf.nn.dynamic_rnn support in XLA AOT?

  14. self-assigned this
    on Sep 19, 2017
  15. 13 remaining items

  16. tensorflowbutler commented on Jan 4, 2018

    @tensorflowbutler
    Member

    It has been 14 days with no activity and this issue has an assignee.Please update the label and/or status accordingly.

  17. lissyx commented on Jan 5, 2018

    @lissyx
    Contributor

    @ebrevdo What happens for a tf.nn.bidirectional_dynamic_rnn with no sequence_length argument? I am currently removing it because tfcompile chokes on Assert. This used to work quite well, but since r1.4, compiling with the recurrent layers, even very small ones, fails in a way that looks like infite loop consuming as much as CPU and memory as possible. Last time I tried master, it was exposing the same behavior.

    My guess is that this is because of the lack of sequence_length, and thus it goes weird.

    However, keeping the sequence_length fails this way:

    2018-01-05 18:29:44.901953: F external/org_tensorflow/tensorflow/compiler/aot/tfcompile_main.cc:140] Non-OK-status: status status: Not found: Op type not registered 'Assert' in binary running on hostname. Make sure the Op and Kernel are registered in the binary running in this process.
    
  18. ebrevdo commented on Jan 5, 2018

    @ebrevdo
    Contributor
  19. tatatodd commented on Jan 5, 2018

    @tatatodd
    Contributor

    Last I heard, @prb12 was working on adding a no-op tf2xla kernel for tf.Assert, he would know more.

  20. added
    stat:awaiting tensorflower
    on Jan 5, 2018
  21. tensorflowbutler commented on Jan 24, 2018

    @tensorflowbutler
    Member

    Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

  22. tensorflowbutler commented on Feb 8, 2018

    @tensorflowbutler
    Member

    Nagging Assignee: It has been 14 days with no activity and this issue has an assignee. Please update the label and/or status accordingly.

  23. lissyx commented on Feb 12, 2018

    @lissyx
    Contributor

    @ebrevdo So, it looks like with current master, it's not an issue anymore ? At least I can again use tfcompile

  24. ebrevdo commented on Feb 12, 2018

    @ebrevdo
    Contributor
  25. carlthome commented on Feb 12, 2018

    @carlthome
    ContributorAuthor

    Nice! Looking forward to testing this again. 🎉

  26. lissyx commented on Feb 13, 2018

    @lissyx
    Contributor

    @ebrevdo Is it supposed to be fixed on r1.5 as well ?

  27. ebrevdo commented on Feb 13, 2018

    @ebrevdo
    Contributor
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

stat:awaiting tensorflower

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions