pytorch  1.8.2
About: PyTorch provides Tensor computation (like NumPy) with strong GPU acceleration and Deep Neural Networks (in Python) built on a tape-based autograd system. LTS (Long Term Support) release.
  Fossies Dox: pytorch-1.8.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Logging.h File Reference
#include <climits>
#include <exception>
#include <functional>
#include <limits>
#include <sstream>
#include <c10/macros/Macros.h>
#include <c10/util/Exception.h>
#include <c10/util/Flags.h>
#include <c10/util/StringUtil.h>
#include <c10/util/logging_is_not_google_glog.h>
Include dependency graph for Logging.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  c10::enforce_detail::EnforceOK
 
class  c10::enforce_detail::EnforceFailMessage
 
struct  c10::DDPLoggingData
 

Namespaces

namespace  c10
 This file contains functionality to take a C++ function and infer its c10::FunctionSchema.
 
namespace  c10::enforce_detail
 Rich logging messages.
 
namespace  c10::detail
 

Macros

#define CAFFE2_LOG_THRESHOLD   INT_MIN
 
#define C10_LOG_EVERY_MS(severity, ms)   LOG(severity)
 
#define C10_LOG_FIRST_N(severity, n)   LOG(severity)
 
#define C10_LOG_EVERY_N(severity, n)   LOG(severity)
 
#define CAFFE_ENFORCE(condition, ...)
 
#define CAFFE_ENFORCE_FINITE(condition, ...)
 
#define CAFFE_ENFORCE_WITH_CALLER(condition, ...)
 
#define CAFFE_THROW(...)    ::c10::ThrowEnforceNotMet(__FILE__, __LINE__, "", ::c10::str(__VA_ARGS__))
 
#define BINARY_COMP_HELPER(name, op)
 
#define CAFFE_ENFORCE_THAT_IMPL(condition, expr, ...)
 
#define CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER(condition, expr, ...)
 
#define CAFFE_ENFORCE_THAT(condition, ...)    CAFFE_ENFORCE_THAT_IMPL((condition), #condition, __VA_ARGS__)
 
#define CAFFE_ENFORCE_EQ(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL(Equals((x), (y)), #x " == " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_NE(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL(NotEquals((x), (y)), #x " != " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_LE(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL(LessEquals((x), (y)), #x " <= " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_LT(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL(Less((x), (y)), #x " < " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_GE(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL(GreaterEquals((x), (y)), #x " >= " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_GT(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL(Greater((x), (y)), #x " > " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_EQ_WITH_CALLER(x, y, ...)
 
#define CAFFE_ENFORCE_NE_WITH_CALLER(x, y, ...)
 
#define CAFFE_ENFORCE_LE_WITH_CALLER(x, y, ...)
 
#define CAFFE_ENFORCE_LT_WITH_CALLER(x, y, ...)    CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER(Less((x), (y)), #x " < " #y, __VA_ARGS__)
 
#define CAFFE_ENFORCE_GE_WITH_CALLER(x, y, ...)
 
#define CAFFE_ENFORCE_GT_WITH_CALLER(x, y, ...)
 
#define C10_LOG_API_USAGE_ONCE(...)
 Very lightweight logging for the first time API usage. More...
 

Typedefs

using c10::EnforceNotMet = ::c10::Error
 

Functions

 C10_DECLARE_int (caffe2_log_level)
 
 C10_DECLARE_bool (caffe2_use_fatal_for_enforce)
 
bool c10::InitCaffeLogging (int *argc, char **argv)
 
void c10::UpdateLoggingLevelsFromFlags ()
 
void c10::ThrowEnforceNotMet (const char *file, const int line, const char *condition, const std::string &msg, const void *caller)
 
void c10::ThrowEnforceFiniteNotMet (const char *file, const int line, const char *condition, const std::string &msg, const void *caller)
 
constexpr bool c10::IsUsingGoogleLogging ()
 
void c10::ShowLogInfoToStderr ()
 A utility to allow one to show log info to stderr after the program starts. More...
 
void c10::SetStackTraceFetcher (std::function< string(void)> fetcher)
 
template<typename T1 , typename T2 >
EnforceFailMessage c10::enforce_detail::Equals (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
EnforceFailMessage c10::enforce_detail::NotEquals (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
EnforceFailMessage c10::enforce_detail::Greater (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
EnforceFailMessage c10::enforce_detail::GreaterEquals (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
EnforceFailMessage c10::enforce_detail::Less (const T1 &x, const T2 &y)
 
template<typename T1 , typename T2 >
EnforceFailMessage c10::enforce_detail::LessEquals (const T1 &x, const T2 &y)
 
void c10::SetAPIUsageLogger (std::function< void(const std::string &)> logger)
 
void c10::LogAPIUsage (const std::string &event)
 
void c10::SetPyTorchDDPUsageLogger (std::function< void(const c10::DDPLoggingData &)> logger)
 
void c10::LogPyTorchDDPUsage (const c10::DDPLoggingData &ddpData)
 
bool c10::detail::LogAPIUsageFakeReturn (const std::string &event)
 

Macro Definition Documentation

◆ BINARY_COMP_HELPER

#define BINARY_COMP_HELPER (   name,
  op 
)
Value:
template <typename T1, typename T2> \
inline EnforceFailMessage name(const T1& x, const T2& y) { \
if (x op y) { \
return EnforceOK(); \
} \
return c10::str(x, " vs ", y); \
}
std::string name
decltype(auto) str(const Args &... args)
Definition: StringUtil.h:88
core.CreateOperator("Slice",["X"],["Y"], starts=(0, 1), ends=(-1, 3)) workspace.FeedBlob("X", np.array()) print("X:", workspace.FetchBlob("X")) workspace.RunOperatorOnce(op) print("Y:", workspace.FetchBlob("Y")) ``` **Result **``` X:Y:```</details >) DOC") .Input(0, "X", "(*Tensor *):tensor to extract slices from") .Input( 1, "starts", "(*Tensor`< int >` *):1D tensor of start-indices for each dimension of data(dimensions following the sliced one might be omitted)") .Input( 2, "ends", "(*Tensor`< int >` *):1D tensor of end-indices for each dimension of data(dimensions following the sliced one might be omitted)") .Arg("starts", "(*Tuple(int) *):list of starting indices") .Arg("ends", "(*Tuple(int) *):list of ending indices") .TensorInferenceFunction([](const OperatorDef& def, const vector<TensorShape>& in) { if (in.size() > 1) { return vector<TensorShape>() op
Definition: slice_op.cc:82

Definition at line 203 of file Logging.h.

◆ C10_LOG_API_USAGE_ONCE

#define C10_LOG_API_USAGE_ONCE (   ...)
Value:
C10_UNUSED static bool C10_ANONYMOUS_VARIABLE(logFlag) = \
#define C10_UNUSED
Definition: Macros.h:130
#define C10_ANONYMOUS_VARIABLE(str)
Definition: Macros.h:84
bool LogAPIUsageFakeReturn(const std::string &event)
Definition: Logging.cpp:123

Very lightweight logging for the first time API usage.

It's beneficial for tracking of individual functionality usage in larger applications.

In order to ensure light-weightedness of logging, we utilize static variable trick - LogAPIUsage will be invoked only once and further invocations will just do an atomic check.

Example: // Logs caller info with an arbitrary text event, if there is a usage. C10_LOG_API_USAGE_ONCE("my_api");

Definition at line 295 of file Logging.h.

◆ C10_LOG_EVERY_MS

#define C10_LOG_EVERY_MS (   severity,
  ms 
)    LOG(severity)

Definition at line 40 of file Logging.h.

◆ C10_LOG_EVERY_N

#define C10_LOG_EVERY_N (   severity,
 
)    LOG(severity)

Definition at line 54 of file Logging.h.

◆ C10_LOG_FIRST_N

#define C10_LOG_FIRST_N (   severity,
 
)    LOG(severity)

Definition at line 47 of file Logging.h.

◆ CAFFE2_LOG_THRESHOLD

#define CAFFE2_LOG_THRESHOLD   INT_MIN

Definition at line 21 of file Logging.h.

◆ CAFFE_ENFORCE

#define CAFFE_ENFORCE (   condition,
  ... 
)
Value:
do { \
__FILE__, __LINE__, #condition, ::c10::str(__VA_ARGS__)); \
} \
} while (false)
#define C10_UNLIKELY(expr)
Definition: Macros.h:176
void ThrowEnforceNotMet(const char *file, const int line, const char *condition, const std::string &msg, const void *caller)
Definition: Logging.cpp:39

Definition at line 101 of file Logging.h.

◆ CAFFE_ENFORCE_EQ

#define CAFFE_ENFORCE_EQ (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL(Equals((x), (y)), #x " == " #y, __VA_ARGS__)

Definition at line 253 of file Logging.h.

◆ CAFFE_ENFORCE_EQ_WITH_CALLER

#define CAFFE_ENFORCE_EQ_WITH_CALLER (   x,
  y,
  ... 
)
Value:
Equals((x), (y)), #x " == " #y, __VA_ARGS__)
#define CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER(condition, expr,...)
Definition: Logging.h:233
EnforceFailMessage Equals(const T1 &x, const T2 &y)
Definition: Logging.h:211

Definition at line 265 of file Logging.h.

◆ CAFFE_ENFORCE_FINITE

#define CAFFE_ENFORCE_FINITE (   condition,
  ... 
)
Value:
do { \
__FILE__, __LINE__, #condition, ::c10::str(__VA_ARGS__)); \
} \
} while (false)
void ThrowEnforceFiniteNotMet(const char *file, const int line, const char *condition, const std::string &msg, const void *caller)
Definition: Logging.cpp:52

Definition at line 109 of file Logging.h.

◆ CAFFE_ENFORCE_GE

#define CAFFE_ENFORCE_GE (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL(GreaterEquals((x), (y)), #x " >= " #y, __VA_ARGS__)

Definition at line 261 of file Logging.h.

◆ CAFFE_ENFORCE_GE_WITH_CALLER

#define CAFFE_ENFORCE_GE_WITH_CALLER (   x,
  y,
  ... 
)
Value:
GreaterEquals((x), (y)), #x " >= " #y, __VA_ARGS__)
EnforceFailMessage GreaterEquals(const T1 &x, const T2 &y)
Definition: Logging.h:214

Definition at line 276 of file Logging.h.

◆ CAFFE_ENFORCE_GT

#define CAFFE_ENFORCE_GT (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL(Greater((x), (y)), #x " > " #y, __VA_ARGS__)

Definition at line 263 of file Logging.h.

◆ CAFFE_ENFORCE_GT_WITH_CALLER

#define CAFFE_ENFORCE_GT_WITH_CALLER (   x,
  y,
  ... 
)
Value:
Greater((x), (y)), #x " > " #y, __VA_ARGS__)
EnforceFailMessage Greater(const T1 &x, const T2 &y)
Definition: Logging.h:213

Definition at line 279 of file Logging.h.

◆ CAFFE_ENFORCE_LE

#define CAFFE_ENFORCE_LE (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL(LessEquals((x), (y)), #x " <= " #y, __VA_ARGS__)

Definition at line 257 of file Logging.h.

◆ CAFFE_ENFORCE_LE_WITH_CALLER

#define CAFFE_ENFORCE_LE_WITH_CALLER (   x,
  y,
  ... 
)
Value:
LessEquals((x), (y)), #x " <= " #y, __VA_ARGS__)
EnforceFailMessage LessEquals(const T1 &x, const T2 &y)
Definition: Logging.h:216

Definition at line 271 of file Logging.h.

◆ CAFFE_ENFORCE_LT

#define CAFFE_ENFORCE_LT (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL(Less((x), (y)), #x " < " #y, __VA_ARGS__)

Definition at line 259 of file Logging.h.

◆ CAFFE_ENFORCE_LT_WITH_CALLER

#define CAFFE_ENFORCE_LT_WITH_CALLER (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER(Less((x), (y)), #x " < " #y, __VA_ARGS__)

Definition at line 274 of file Logging.h.

◆ CAFFE_ENFORCE_NE

#define CAFFE_ENFORCE_NE (   x,
  y,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL(NotEquals((x), (y)), #x " != " #y, __VA_ARGS__)

Definition at line 255 of file Logging.h.

◆ CAFFE_ENFORCE_NE_WITH_CALLER

#define CAFFE_ENFORCE_NE_WITH_CALLER (   x,
  y,
  ... 
)
Value:
NotEquals((x), (y)), #x " != " #y, __VA_ARGS__)
EnforceFailMessage NotEquals(const T1 &x, const T2 &y)
Definition: Logging.h:212

Definition at line 268 of file Logging.h.

◆ CAFFE_ENFORCE_THAT

#define CAFFE_ENFORCE_THAT (   condition,
  ... 
)     CAFFE_ENFORCE_THAT_IMPL((condition), #condition, __VA_ARGS__)

Definition at line 250 of file Logging.h.

◆ CAFFE_ENFORCE_THAT_IMPL

#define CAFFE_ENFORCE_THAT_IMPL (   condition,
  expr,
  ... 
)
Value:
do { \
using namespace ::c10::enforce_detail; \
const EnforceFailMessage& CAFFE_ENFORCE_THAT_IMPL_r_ = (condition); \
if (C10_UNLIKELY(CAFFE_ENFORCE_THAT_IMPL_r_.bad())) { \
__FILE__, \
__LINE__, \
expr, \
CAFFE_ENFORCE_THAT_IMPL_r_.get_message_and_free( \
::c10::str(__VA_ARGS__))); \
} \
} while (false)

Definition at line 219 of file Logging.h.

◆ CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER

#define CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER (   condition,
  expr,
  ... 
)
Value:
do { \
using namespace ::c10::enforce_detail; \
const EnforceFailMessage& CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER_r_ = \
(condition); \
if (C10_UNLIKELY(CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER_r_.bad())) { \
__FILE__, \
__LINE__, \
expr, \
CAFFE_ENFORCE_THAT_IMPL_WITH_CALLER_r_.get_message_and_free( \
::c10::str(__VA_ARGS__)), \
this); \
} \
} while (false)

Definition at line 233 of file Logging.h.

◆ CAFFE_ENFORCE_WITH_CALLER

#define CAFFE_ENFORCE_WITH_CALLER (   condition,
  ... 
)
Value:
do { \
__FILE__, __LINE__, #condition, ::c10::str(__VA_ARGS__), this); \
} \
} while (false)

Definition at line 117 of file Logging.h.

◆ CAFFE_THROW

#define CAFFE_THROW (   ...)     ::c10::ThrowEnforceNotMet(__FILE__, __LINE__, "", ::c10::str(__VA_ARGS__))

Definition at line 125 of file Logging.h.

Function Documentation

◆ C10_DECLARE_bool()

C10_DECLARE_bool ( caffe2_use_fatal_for_enforce  )

◆ C10_DECLARE_int()

C10_DECLARE_int ( caffe2_log_level  )