szha commented on a change in pull request #10511: add naming tutorial URL: https://github.com/apache/incubator-mxnet/pull/10511#discussion_r181282688
########## File path: python/mxnet/gluon/block.py ########## @@ -187,17 +187,17 @@ def __setattr__(self, name, value): existing = getattr(self, name) if isinstance(existing, (Parameter, Block)) and not isinstance(value, type(existing)): raise TypeError('Changing attribute type for {name} from {type1} to {type2}' \ - 'is not allowed.'.format(name=name, - type1=type(existing), - type2=type(value))) - if isinstance(existing, Block): - for i, c in enumerate(self._children): - if c is existing: - self._children[i] = value - elif isinstance(value, Block): - self.register_child(value) - elif isinstance(value, Block): - self.register_child(value) + 'is not allowed.'.format( + name=name, type1=type(existing), type2=type(value))) + + if isinstance(value, Block): + self.register_child(value, name) Review comment: Removing the block update logic can cause having stale blocks in `_children`. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services