|
|
@ -102,6 +102,15 @@ struct EnforceNotMet : public std::exception {
|
|
|
|
const char* what() const noexcept { return err_str_.c_str(); }
|
|
|
|
const char* what() const noexcept { return err_str_.c_str(); }
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct EOFException : public std::exception {
|
|
|
|
|
|
|
|
std::string err_str_;
|
|
|
|
|
|
|
|
EOFException(const char* err_msg, const char* f, int l) {
|
|
|
|
|
|
|
|
err_str_ = string::Sprintf("%s at [%s:%d]", err_msg, f, l);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const char* what() const noexcept { return err_str_.c_str(); }
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// Because most enforce conditions would evaluate to true, we can use
|
|
|
|
// Because most enforce conditions would evaluate to true, we can use
|
|
|
|
// __builtin_expect to instruct the C++ compiler to generate code that
|
|
|
|
// __builtin_expect to instruct the C++ compiler to generate code that
|
|
|
|
// always forces branch prediction of true.
|
|
|
|
// always forces branch prediction of true.
|
|
|
@ -242,6 +251,11 @@ inline void throw_on_error(T e) {
|
|
|
|
#define PADDLE_ENFORCE(...) ::paddle::platform::throw_on_error(__VA_ARGS__);
|
|
|
|
#define PADDLE_ENFORCE(...) ::paddle::platform::throw_on_error(__VA_ARGS__);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#define PADDLE_THROW_EOF() \
|
|
|
|
|
|
|
|
do { \
|
|
|
|
|
|
|
|
throw ::paddle::platform::EOFException("There is no next data.", __FILE__, \
|
|
|
|
|
|
|
|
__LINE__); \
|
|
|
|
|
|
|
|
} while (false)
|
|
|
|
/*
|
|
|
|
/*
|
|
|
|
* Some enforce helpers here, usage:
|
|
|
|
* Some enforce helpers here, usage:
|
|
|
|
* int a = 1;
|
|
|
|
* int a = 1;
|
|
|
|