aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/python/util
diff options
context:
space:
mode:
authorGravatar Allen Lavoie <allenl@google.com>2018-07-24 15:03:46 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-24 15:11:40 -0700
commiteabda97225faf53ec528621299f5b6c57a7847b0 (patch)
treea831a1f5170a389d09eb956133622931e677d266 /tensorflow/python/util
parentd09afb711610b88f394d318622e862fcd327f440 (diff)
Dictionary tracking for tf.keras.Model attribute assignment
Does not inherit from dict (and so won't pass isinstance checks). I've written a small tome about why in a comment on the class definition. This seems not to break anyone, but if it does we can add Mapping to the problematic isinstance checks (as I've done for TF's nest util and Session fetching); ideally custom mappings would be supported everywhere dicts are anyway. PiperOrigin-RevId: 205898305
Diffstat (limited to 'tensorflow/python/util')
-rw-r--r--tensorflow/python/util/util.cc9
1 files changed, 6 insertions, 3 deletions
diff --git a/tensorflow/python/util/util.cc b/tensorflow/python/util/util.cc
index f9e0b7e4d2..ad85a44f8d 100644
--- a/tensorflow/python/util/util.cc
+++ b/tensorflow/python/util/util.cc
@@ -506,9 +506,12 @@ bool AssertSameStructureHelper(PyObject* o1, PyObject* o2, bool check_types,
}
} else if (type1 != type2
/* If both sequences are list types, don't complain. This allows
- one to be a list subclass (e.g. _ListWrapper used for automatic
- dependency tracking.) */
- && !(PyList_Check(o1) && PyList_Check(o2))) {
+ one to be a list subclass (e.g. _ListWrapper used for
+ automatic dependency tracking.) */
+ && !(PyList_Check(o1) && PyList_Check(o2))
+ /* Two mapping types will also compare equal, making _DictWrapper
+ and dict compare equal. */
+ && !(IsMappingHelper(o1) && IsMappingHelper(o2))) {
*is_type_error = true;
*error_msg = tensorflow::strings::StrCat(
"The two namedtuples don't have the same sequence type. "