[tf.data] Optimize `Dataset.filter()` when the predicate returns one of its args.
authorDerek Murray <mrry@google.com>
Wed, 7 Mar 2018 22:02:15 +0000 (14:02 -0800)
committerTensorFlower Gardener <gardener@tensorflow.org>
Wed, 7 Mar 2018 22:06:32 +0000 (14:06 -0800)
commit2941052ddcc140becd43cc96da6664028217182d
tree330ad6cc16930281386702e3b24e8448de72f9ae
parent10fe6cae69f551408441fa275b2ff42da5d47647
[tf.data] Optimize `Dataset.filter()` when the predicate returns one of its args.

This change avoids the overhead of function dispatch (~10--15us) when
the filter predicate simply returns one of its arguments directly. It
also adds a benchmark to track the performance of this optimization.

The checkpointing code required minor modifications to enable functions to be
instantiated in the `FilterDatasetOp::Compute()` method when an iterator is being
restored.

PiperOrigin-RevId: 188229570
tensorflow/core/kernels/data/BUILD
tensorflow/core/kernels/data/filter_dataset_op.cc
tensorflow/core/kernels/data/iterator_ops.cc
tensorflow/python/data/kernel_tests/filter_dataset_op_test.py