1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
|
#include <c10/cuda/CUDAException.h>
#include <c10/util/Exception.h>
#include <cuda_runtime.h>
#include <string>
namespace c10 {
namespace cuda {
void c10_cuda_check_implementation(
const std::string& filename,
const std::string& function_name,
const int line_number,
const bool include_device_assertions) {
// We retrieve the error here in order to keep CUDA data types out of
// CUDAException.h thereby simplifying including it in other files
const cudaError_t err = cudaGetLastError();
if (C10_LIKELY(err == cudaSuccess)) {
return;
}
std::string check_message;
#ifndef STRIP_ERROR_MESSAGES
check_message.append("CUDA error: ");
check_message.append(cudaGetErrorString(err));
check_message.append(c10::cuda::get_cuda_check_suffix());
#endif
TORCH_CHECK(false, check_message);
}
} // namespace cuda
} // namespace c10
|