Shortcuts

Class Error

Inheritance Relationships

Base Type

  • public std::exception

Derived Types

Class Documentation

class Error : public std::exception

The primary ATen error class.

Provides a complete error message with source location information via what(), and a more concise message via what_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 by c10::DistError, c10::EnforceFiniteError, c10::ErrorAlwaysShowCppStacktrace, c10::IndexError, c10::LinAlgError, c10::NotImplementedError, c10::OnnxfiBackendSystemError, c10::OutOfMemoryError, c10::TypeError, c10::ValueError

Public Functions

Error(SourceLocation source_location, std::string msg)
Error(const char *file, const uint32_t line, const char *condition, const std::string &msg, Backtrace backtrace, const void *caller = nullptr)
Error(std::string msg, Backtrace backtrace = nullptr, const void *caller = nullptr)
void add_context(std::string msg)
inline const std::string &msg() const
inline const std::vector<std::string> &context() const
const Backtrace &backtrace() const
const char *what() const noexcept override

Returns the complete error message, including the source location.

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

inline const void *caller() const noexcept
inline virtual const char *what_without_backtrace() const noexcept

Returns only the error message string, without source location.

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

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources