Caffe2 - C++ API
A deep learning, cross platform ML framework
Data Structures
c10::enforce_detail Namespace Reference

Rich logging messages. More...

Data Structures

class  EnforceFailMessage
struct  EnforceOK

Detailed Description

Rich logging messages.

CAFFE_ENFORCE_THAT can be used with one of the "checker functions" that capture input argument values and add it to the exception message. E.g. CAFFE_ENFORCE_THAT(Equals(foo(x), bar(y)), "Optional additional message") would evaluate both foo and bar only once and if the results are not equal - include them in the exception message.

Some of the basic checker functions like Equals or Greater are already defined below. Other header might define customized checkers by adding functions to caffe2::enforce_detail namespace. For example:

namespace caffe2 { namespace enforce_detail { inline EnforceFailMessage IsVector(const vector<int64_t>& shape) { if (shape.size() == 1) { return EnforceOK(); } return c10::str("Shape ", shape, " is not a vector"); } }}

With further usages like CAFFE_ENFORCE_THAT(IsVector(Input(0).dims()))

Convenient wrappers for binary operations like CAFFE_ENFORCE_EQ are provided too. Please use them instead of CHECK_EQ and friends for failures in user-provided input.