Shortcuts

Class Error

Inheritance Relationships

Base Type

  • public exception

Derived Types

Class Documentation

class c10::Error : public 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::EnforceFiniteError, c10::IndexError, c10::NotImplementedError, c10::OnnxfiBackendSystemError, 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, const std::string &backtrace, const void *caller = nullptr)
Error(std::string msg, std::string backtrace, const void *caller = nullptr)
void add_context(std::string msg)
const std::string &msg() const
const std::vector<std::string> &context() const
const std::string &backtrace() const
const char * what () const noexceptoverride

Returns the complete error message, including the source location.

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

const void *caller() const noexcept
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