Implement assert_same_structure in C++
authorIgor Ganichev <iga@google.com>
Thu, 29 Mar 2018 01:26:30 +0000 (18:26 -0700)
committerTensorFlower Gardener <gardener@tensorflow.org>
Thu, 29 Mar 2018 01:29:02 +0000 (18:29 -0700)
commit17dfe3ed7db7fb4d41f8933adead4737c30a92c9
tree3340da23f054786503a067dfe6d62fbc8f9d7c14
parent628552228c76d2ee7f2eef4d56175a89941e3e1d
Implement assert_same_structure in C++

Also implements helper functions nest._is_namedtuple
nest._same_namedtuple.

Also, fix a bug in FlattenHelper where error from recursive
calls were not propagated up immediately.

This change implements a good chunk of machinery that will
allow us to move map_structure to C++.

Before:
entry {
  name: "NestBenchmark.assert_same_structure_6_elem"
  iters: 30000
  wall_time: 4.79532718658e-05
}

entry {
  name: "NestBenchmark.assert_same_structure_60_elem"
  iters: 30000
  wall_time: 0.000403008667628
}

After:
entry {
  name: "NestBenchmark.assert_same_structure_6_elem"
  iters: 30000
  wall_time: 1.65301720301e-05
}

entry {
  name: "NestBenchmark.assert_same_structure_60_elem"
  iters: 30000
  wall_time: 0.000147621099154
}

PiperOrigin-RevId: 190869007
tensorflow/python/BUILD
tensorflow/python/framework/test_util.py
tensorflow/python/kernel_tests/functional_ops_test.py
tensorflow/python/util/nest.py
tensorflow/python/util/nest_test.py
tensorflow/python/util/util.cc
tensorflow/python/util/util.h
tensorflow/python/util/util.i