|
|
|
@ -113,7 +113,11 @@ template <typename... Args>
|
|
|
|
|
inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
|
|
|
|
|
bool stat, const Args&... args) {
|
|
|
|
|
if (UNLIKELY(!(stat))) {
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
throw std::runtime_error(string::Sprintf(args...));
|
|
|
|
|
#else
|
|
|
|
|
LOG(FATAL) << string::Sprintf(args...);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -123,8 +127,12 @@ template <typename... Args>
|
|
|
|
|
inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
|
|
|
|
|
cudaError_t e, const Args&... args) {
|
|
|
|
|
if (UNLIKELY(e)) {
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
throw thrust::system_error(e, thrust::cuda_category(),
|
|
|
|
|
string::Sprintf(args...));
|
|
|
|
|
#else
|
|
|
|
|
LOG(FATAL) << string::Sprintf(args...);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -132,8 +140,12 @@ template <typename... Args>
|
|
|
|
|
inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
|
|
|
|
|
curandStatus_t stat, const Args&... args) {
|
|
|
|
|
if (stat != CURAND_STATUS_SUCCESS) {
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
throw thrust::system_error(cudaErrorLaunchFailure, thrust::cuda_category(),
|
|
|
|
|
string::Sprintf(args...));
|
|
|
|
|
#else
|
|
|
|
|
LOG(FATAL) << string::Sprintf(args...);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -143,8 +155,12 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
|
|
|
|
|
if (stat == CUDNN_STATUS_SUCCESS) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
throw std::runtime_error(platform::dynload::cudnnGetErrorString(stat) +
|
|
|
|
|
string::Sprintf(args...));
|
|
|
|
|
#else
|
|
|
|
|
LOG(FATAL) << string::Sprintf(args...);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -173,7 +189,11 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
|
|
|
|
|
} else if (stat == CUBLAS_STATUS_LICENSE_ERROR) {
|
|
|
|
|
err = "CUBLAS: license error, ";
|
|
|
|
|
}
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
throw std::runtime_error(err + string::Sprintf(args...));
|
|
|
|
|
#else
|
|
|
|
|
LOG(FATAL) << err << string::Sprintf(args...);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#ifndef __APPLE__
|
|
|
|
@ -183,8 +203,13 @@ inline typename std::enable_if<sizeof...(Args) != 0, void>::type throw_on_error(
|
|
|
|
|
if (stat == ncclSuccess) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
throw std::runtime_error(platform::dynload::ncclGetErrorString(stat) +
|
|
|
|
|
string::Sprintf(args...));
|
|
|
|
|
#else
|
|
|
|
|
LOG(FATAL) << platform::dynload::ncclGetErrorString(stat)
|
|
|
|
|
<< string::Sprintf(args...);
|
|
|
|
|
#endif
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endif // __APPLE__
|
|
|
|
@ -203,6 +228,7 @@ inline void throw_on_error(T e) {
|
|
|
|
|
__FILE__, __LINE__); \
|
|
|
|
|
} while (false)
|
|
|
|
|
|
|
|
|
|
#ifndef REPLACE_ENFORCE_GLOG
|
|
|
|
|
#define PADDLE_ENFORCE(...) \
|
|
|
|
|
do { \
|
|
|
|
|
try { \
|
|
|
|
@ -212,6 +238,9 @@ inline void throw_on_error(T e) {
|
|
|
|
|
__FILE__, __LINE__); \
|
|
|
|
|
} \
|
|
|
|
|
} while (false)
|
|
|
|
|
#else
|
|
|
|
|
#define PADDLE_ENFORCE(...) ::paddle::platform::throw_on_error(__VA_ARGS__);
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Some enforce helpers here, usage:
|
|
|
|
|