-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
22 changed files
with
1,029 additions
and
2,740 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
//! Provides Rust Errors for CUDA's cuDNN status. | ||
|
||
use std::{fmt, error}; | ||
|
||
#[derive(Debug, Copy, Clone)] | ||
/// Defines CUDA's cuDNN errors. | ||
pub enum Error { | ||
/// Failure with CUDA cuDNN initialization. | ||
NotInitialized(&'static str), | ||
/// Failure with allocation. | ||
AllocFailed(&'static str), | ||
/// Failure with a provided parameter. | ||
BadParam(&'static str), | ||
/// Failure with cuDNN. | ||
InternalError(&'static str), | ||
/// Failure with provided value. | ||
InvalidValue(&'static str), | ||
/// Failure with the hardware architecture. | ||
ArchMismatch(&'static str), | ||
/// Failure with memory access or internal error/bug. | ||
MappingError(&'static str), | ||
/// Failure with Kernel execution. | ||
ExecutionFailed(&'static str), | ||
/// Failure with an unsupported request. | ||
NotSupported(&'static str), | ||
/// Failure Cuda License. | ||
LicenseError(&'static str), | ||
} | ||
|
||
impl fmt::Display for Error { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
match *self { | ||
Error::NotInitialized(ref err) => write!(f, "{:?}", err), | ||
Error::AllocFailed(ref err) => write!(f, "{:?}", err), | ||
Error::BadParam(ref err) => write!(f, "{:?}", err), | ||
Error::InternalError(ref err) => write!(f, "{:?}", err), | ||
Error::InvalidValue(ref err) => write!(f, "{:?}", err), | ||
Error::ArchMismatch(ref err) => write!(f, "{:?}", err), | ||
Error::MappingError(ref err) => write!(f, "{:?}", err), | ||
Error::ExecutionFailed(ref err) => write!(f, "{:?}", err), | ||
Error::NotSupported(ref err) => write!(f, "{:?}", err), | ||
Error::LicenseError(ref err) => write!(f, "{:?}", err), | ||
} | ||
} | ||
} | ||
|
||
impl error::Error for Error { | ||
fn description(&self) -> &str { | ||
match *self { | ||
Error::NotInitialized(ref err) => err, | ||
Error::AllocFailed(ref err) => err, | ||
Error::BadParam(ref err) => err, | ||
Error::InternalError(ref err) => err, | ||
Error::InvalidValue(ref err) => err, | ||
Error::ArchMismatch(ref err) => err, | ||
Error::MappingError(ref err) => err, | ||
Error::ExecutionFailed(ref err) => err, | ||
Error::NotSupported(ref err) => err, | ||
Error::LicenseError(ref err) => err, | ||
} | ||
} | ||
|
||
fn cause(&self) -> Option<&error::Error> { | ||
match *self { | ||
Error::NotInitialized(_) => None, | ||
Error::AllocFailed(_) => None, | ||
Error::BadParam(_) => None, | ||
Error::InternalError(_) => None, | ||
Error::InvalidValue(_) => None, | ||
Error::ArchMismatch(_) => None, | ||
Error::MappingError(_) => None, | ||
Error::ExecutionFailed(_) => None, | ||
Error::NotSupported(_) => None, | ||
Error::LicenseError(_) => None, | ||
} | ||
} | ||
} |
Oops, something went wrong.