ankkhedia commented on a change in pull request #10424: Improved error message URL: https://github.com/apache/incubator-mxnet/pull/10424#discussion_r179857275
########## File path: python/mxnet/gluon/block.py ########## @@ -458,7 +458,11 @@ def _build_cache(self, *args): for name in out.list_inputs()] def _finish_deferred_init(self, hybrid, *args): - self.infer_shape(*args) + try: + self.infer_shape(*args) + except Exception: Review comment: @piiswrong Which place should you think will be good for this exception to be caught? If we want to catch exception for error in deferred initialization, it won't be possible in lower function stack (self.infer_shape or even further down in self._infer_atttrs or sym.infer_shape) as those are generic functions and not specific to deferred initialization. The actual place where error happens is sym.infer_shape in symbols.py. Here (symbol.py) the infer shape returns none. However, we can't through an error over here because its not an error and sometimes a symbol whose inferred shape is returned as the symbol can be be initialised later as as part of deferred initialization. I agree that error message should contain more information about parameter but we can only obtain block name at this point in code (if we are throwing exception from this point). I can add that name in the error message. What do you think should be a good way to go about it? ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on 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 With regards, Apache Git Services