提交 6d55c43b authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Use original traceback when raising shape errors

上级 1ff98d25
...@@ -1068,7 +1068,7 @@ class ShapeFeature(object): ...@@ -1068,7 +1068,7 @@ class ShapeFeature(object):
"indicate that a shape cannot be computed is no longer " "indicate that a shape cannot be computed is no longer "
"supported, and one should now use tensor.ShapeError " "supported, and one should now use tensor.ShapeError "
"instead. The original exception message is: %s" % e "instead. The original exception message is: %s" % e
) ).with_traceback(e.__traceback__)
except Exception as e: except Exception as e:
msg = ( msg = (
"Failed to infer_shape from Op %s.\nInput shapes: " "Failed to infer_shape from Op %s.\nInput shapes: "
...@@ -1082,7 +1082,7 @@ class ShapeFeature(object): ...@@ -1082,7 +1082,7 @@ class ShapeFeature(object):
traceback.format_exc(), traceback.format_exc(),
) )
if config.on_shape_error == "raise": if config.on_shape_error == "raise":
raise Exception(msg) raise Exception(msg).with_traceback(e.__traceback__)
else: else:
_logger.warning(msg) _logger.warning(msg)
o_shapes = self.default_infer_shape( o_shapes = self.default_infer_shape(
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论