You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/07/01 19:26:37 UTC

[GitHub] [incubator-mxnet] samskalicky commented on a change in pull request #18405: Add deleting of args aux aux to Partition API

samskalicky commented on a change in pull request #18405:
URL: https://github.com/apache/incubator-mxnet/pull/18405#discussion_r448571094



##########
File path: python/mxnet/gluon/block.py
##########
@@ -1073,8 +1060,35 @@ def _build_cache(self, *args):
                         for name in out.list_auxiliary_states()}
             # Partition the graph.
             out = out.optimize_for(self._backend, arg_dict, aux_dict, ctx, **self._backend_opts)
+            # BFS to delete the delete args/aux from the block Params and its children's Params
+            input_names = out.list_inputs()
+            queue = [self]
+            while len(queue) > 0:
+                curr_block = queue.pop(0)
+                curr_params = curr_block.params if isinstance(curr_block.params, dict) else curr_block.params._params
+                curr_params_names = list(curr_params.keys())
+                for k in curr_params_names:
+                    if k not in input_names:
+                        curr_params.pop(k)

Review comment:
       removing params from a python-level block puts the model in bad state, because now it doesnt work in Python. @leezu 




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org