Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Delete args from Block.params
Browse files Browse the repository at this point in the history
Signed-off-by: Serge Panev <spanev@nvidia.com>
  • Loading branch information
Kh4L committed Jun 12, 2020
1 parent 6e921ea commit 6652047
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions python/mxnet/gluon/block.py
Original file line number Diff line number Diff line change
Expand Up @@ -1026,6 +1026,18 @@ 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_names = list(curr_block.params._params.keys())
for k in curr_params_names:
if k not in input_names:
curr_block.params._params.pop(k)

queue.extend(curr_block._children.values())

#update cached graph with partitioned graph
self._cached_graph = data, out

Expand Down

0 comments on commit 6652047

Please sign in to comment.