From 16ba087b640b37958cc90a8c169bf641751cb487 Mon Sep 17 00:00:00 2001 From: Dmytro Dzhulgakov Date: Mon, 5 Mar 2018 19:59:55 -0800 Subject: [PATCH] [oncall]fix unittest dper/layer_models/tests:utils_test as titled -- fix offending diff D7091725 due to added debug_info in operator proto --- caffe2/python/layer_model_helper.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/caffe2/python/layer_model_helper.py b/caffe2/python/layer_model_helper.py index 388bb0d939dbf2..e24ad8a7c9c2b7 100644 --- a/caffe2/python/layer_model_helper.py +++ b/caffe2/python/layer_model_helper.py @@ -171,6 +171,18 @@ def maybe_add_global_constant(self, name, *args, **kwargs): # To ad hoc add new global constants without duplication # if the name was already registered in global_constants, it will not be # added even if the intended value is different from its original value + + def op_equal(operator1, operator2): + o1 = copy.deepcopy(operator1) + o2 = copy.deepcopy(operator2) + # debug_info is supposed to be different, and we don't need to + # compare debug_info + if hasattr(o1, 'debug_info'): + o1.debug_info = '' + if hasattr(o2, 'debug_info'): + o2.debug_info = '' + return o1 == o2 + if name in self.global_constants: blob_name = self.global_constants[name] initializer_op = \ @@ -179,8 +191,8 @@ def maybe_add_global_constant(self, name, *args, **kwargs): ) # check if the original initializer is the same as the one intended # now - assert initializer_op == \ - self.global_constant_initializers[blob_name], \ + assert op_equal(initializer_op, + self.global_constant_initializers[blob_name]), \ "conflict initializers for global constant %s, " \ "previous %s, now %s" % ( blob_name, str(initializer_op),