Kh4L commented on a change in pull request #18405: URL: https://github.com/apache/incubator-mxnet/pull/18405#discussion_r450372178
########## File path: python/mxnet/symbol/symbol.py ########## @@ -1544,8 +1544,35 @@ def optimize_for(self, backend, args=None, aux=None, ctx=None, **kwargs): raise RuntimeError('Cannot add new aux in optimize_for since aux is None\n' + 'Provide a dictionary to the aux argument to optimize_for') - # return modified symbol - return Symbol(out) + new_sym = Symbol(out) + + arg_names = self.list_arguments() + new_arg_names = new_sym.list_arguments() + deleted_arg_names = set([item for item in arg_names + if item not in set(new_arg_names)]) + + if len(deleted_arg_names) > 0: + if args is not None: + for a_n in deleted_arg_names: + if a_n in args: + args.pop(a_n) + else: + warnings.warn('optimize_for deleted some argument. \n' + + 'Provide a dictionary to the arg argument to optimize_for') Review comment: Thanks for the suggestion! I think that this new message will be sufficient, printing the list of deleted arg names could be potentially very long and flood the stderr ---------------------------------------------------------------- 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