Rate this Page

Class Error#

Inheritance Relationships#

Base Type#

  • publicstd::exception

Derived Types#

Class Documentation#

classError:publicstd::exception#

The primary ATen error class.

Provides a complete error message with source location information viawhat(), and a more concise message viawhat_without_backtrace(). Don’t throw this directly; use TORCH_CHECK/TORCH_INTERNAL_ASSERT instead.

NB:c10::Error is handled specially by the default torch to suppress the backtrace, see torch/csrc/Exceptions.h

Subclassed byc10::AcceleratorError,c10::BufferError,c10::DistError,c10::EnforceFiniteError,c10::ErrorAlwaysShowCppStacktrace,c10::IndexError,c10::LinAlgError,c10::NotImplementedError,c10::OnnxfiBackendSystemError,c10::OutOfMemoryError,c10::SyntaxError,c10::TypeError,c10::ValueError

Public Functions

Error(SourceLocationsource_location,std::stringmsg)#
Error(constchar*file,constuint32_tline,constchar*condition,conststd::string&msg,Backtracebacktrace,constvoid*caller=nullptr)#
Error(std::stringmsg,Backtracebacktrace=nullptr,constvoid*caller=nullptr)#
voidadd_context(std::stringmsg)#
inlineconststd::string&msg()const#
inlineconststd::vector<std::string>&context()const#
constBacktrace&backtrace()const#
constchar*what()constnoexceptoverride#

Returns the complete error message, including the source location.

The returned pointer is invalidated if you calladd_context() on this object.

inlineconstvoid*caller()constnoexcept#
inlinevirtualconstchar*what_without_backtrace()constnoexcept#

Returns only the error message string, without source location.

The returned pointer is invalidated if you calladd_context() on this object.