You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by zh...@apache.org on 2018/08/12 20:23:03 UTC
[incubator-mxnet] branch master updated: Do not show "needs to
register block" warning for registered blocks. (#12130)
This is an automated email from the ASF dual-hosted git repository.
zhasheng pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git
The following commit(s) were added to refs/heads/master by this push:
new 0d68079 Do not show "needs to register block" warning for registered blocks. (#12130)
0d68079 is described below
commit 0d68079ae3107a39bc37ed39e277346df1a56b57
Author: Alexander Alexandrov <al...@gmail.com>
AuthorDate: Sun Aug 12 13:22:55 2018 -0700
Do not show "needs to register block" warning for registered blocks. (#12130)
---
python/mxnet/gluon/block.py | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py
index af54c66..d0830dc 100644
--- a/python/mxnet/gluon/block.py
+++ b/python/mxnet/gluon/block.py
@@ -208,26 +208,27 @@ class Block(object):
super(Block, self).__setattr__(name, value)
def _check_container_with_block(self):
- def _find_block_in_container(data):
+ children = set(self._children.values())
+ def _find_unregistered_block_in_container(data):
# Find whether a nested container structure contains Blocks
if isinstance(data, (list, tuple)):
for ele in data:
- if _find_block_in_container(ele):
+ if _find_unregistered_block_in_container(ele):
return True
return False
elif isinstance(data, dict):
for _, v in data.items():
- if _find_block_in_container(v):
+ if _find_unregistered_block_in_container(v):
return True
return False
elif isinstance(data, Block):
- return True
+ return not data in children
else:
return False
for k, v in self.__dict__.items():
if isinstance(v, (list, tuple, dict)) and not (k.startswith('__') or k == '_children'):
- if _find_block_in_container(v):
- warnings.warn('"{name}" is a container with Blocks. '
+ if _find_unregistered_block_in_container(v):
+ warnings.warn('"{name}" is an unregistered container with Blocks. '
'Note that Blocks inside the list, tuple or dict will not be '
'registered automatically. Make sure to register them using '
'register_child() or switching to '