Skip to content

Commit

Permalink
[oncall]fix unittest dper/layer_models/tests:utils_test
Browse files Browse the repository at this point in the history
as titled -- fix offending diff D7091725 due to added debug_info in operator
proto
  • Loading branch information
Dmytro Dzhulgakov authored and dzhulgakov committed Mar 6, 2018
1 parent 496c999 commit 16ba087
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions caffe2/python/layer_model_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 = \
Expand All @@ -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),
Expand Down

0 comments on commit 16ba087

Please sign in to comment.