diff --git a/mindspore/ccsrc/utils/log_adapter.cc b/mindspore/ccsrc/utils/log_adapter.cc index b23916b4fef9142267957716323fda06db85a42a..74a66f44d75954ca35cd9279870a4b5280564cae 100644 --- a/mindspore/ccsrc/utils/log_adapter.cc +++ b/mindspore/ccsrc/utils/log_adapter.cc @@ -143,6 +143,7 @@ static std::string ExceptionTypeToString(ExceptionType type) { _TO_STRING(TimeOutError), _TO_STRING(ResourceUnavailable), _TO_STRING(NoPermissionError), + _TO_STRING(IndexError), _TO_STRING(ValueError), _TO_STRING(TypeError), }; @@ -179,7 +180,8 @@ void LogWriter::operator^(const LogStream &stream) const { std::ostringstream oss; oss << location_.file_ << ":" << location_.line_ << " " << location_.func_ << "] "; - if (exception_type_ != NoExceptionType && exception_type_ != TypeError && exception_type_ != ValueError) { + if (exception_type_ != NoExceptionType && exception_type_ != IndexError && exception_type_ != TypeError && + exception_type_ != ValueError) { oss << ExceptionTypeToString(exception_type_) << " "; } oss << msg.str(); @@ -187,6 +189,9 @@ void LogWriter::operator^(const LogStream &stream) const { trace::TraceGraphInfer(); trace::GetInferStackInfo(oss); + if (exception_type_ == IndexError) { + throw pybind11::index_error(oss.str()); + } if (exception_type_ == ValueError) { throw pybind11::value_error(oss.str()); } diff --git a/mindspore/ccsrc/utils/log_adapter.h b/mindspore/ccsrc/utils/log_adapter.h index 2122870c3b11b102ed20830f6aec927887b817b2..d7d8eff23e8358c88b757b6361ce96b4b640dee0 100644 --- a/mindspore/ccsrc/utils/log_adapter.h +++ b/mindspore/ccsrc/utils/log_adapter.h @@ -54,6 +54,7 @@ enum ExceptionType { TimeOutError, ResourceUnavailable, NoPermissionError, + IndexError, ValueError, TypeError, };