tensorflow: tfcompile with tf.nn.dynamic_rnn crashes
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?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 35 (31 by maintainers)
It is a goal; but because XLA will JIT a graph and perform memory layout before any execution, you will have to provide a “maximum max_time” for the memory layout (even if the loop will not calculate up to this maximum size). When working with dynamic_rnn, for example, this will mean you will have to pad your batched sequence inputs to some specific max_time size(s), like 10, 50, 100, …; to ensure XLA doesn’t try to JIT compile for every possible max(sequence_length) across your minibatches. The tensorflow NMT tutorial shows how to bucket batches by sequence lengths, but does not currently pad the input max_times to the bucket boundaries.
On Wed, Dec 20, 2017 at 8:49 AM, leod notifications@github.com wrote:
I tried again just now with master and still failing with
INVALID ARGUMENTS: Input 0 of node encoder/rnn/while/add/y was passed int32 from encoder/rnn/while/Switch:1 incompatible with expected INVALID.
@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
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:
outgraph.config.pbtxt:
BUILD file:
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 totf.nn.static_rnn
works however.Here’s a complete example.