Kh4L commented on a change in pull request #18405: URL: https://github.com/apache/incubator-mxnet/pull/18405#discussion_r433642267
########## File path: python/mxnet/symbol/symbol.py ########## @@ -1554,7 +1563,40 @@ def optimize_for(self, backend, args=None, aux=None, ctx=None, **kwargs): aux[idx] = NDArray(NDArrayHandle(new_aux_handle[i])) else: aux.append(NDArray(NDArrayHandle(new_aux_handle[i]))) - return Symbol(out) + + new_sym = Symbol(out) + + new_arg_names = new_sym.list_arguments() + deleted_arg_names = [item for item in arg_names + if item not in set(new_arg_names)] + + new_aux_names = new_sym.list_auxiliary_states() + deleted_aux_names = [item for item in aux_names + if item not in set(new_aux_names)] + + if isinstance(args, dict): + for a_n in deleted_arg_names: + if a_n in args: + args.pop(a_n) + + if isinstance(aux, dict): + for a_n in deleted_aux_names: + if a_n in aux: + aux.pop(a_n) Review comment: Actually yes, at first I wanted to give control to the user when params are provided as lists (so they can delete the extra params themselves), but then I chose to do it implicitly when params are given as dicts. I will remove these cumbersome `delete_x` and do the same as what is done for dicts. ---------------------------------------------------------------- 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: us...@infra.apache.org