pub enum TensorError {
Show 23 variants
ShapeMismatch {
operation: String,
expected: String,
got: String,
context: Option<ErrorContext>,
},
DeviceMismatch {
operation: String,
device1: String,
device2: String,
context: Option<ErrorContext>,
},
UnsupportedDevice {
operation: String,
device: String,
fallback_available: bool,
context: Option<ErrorContext>,
},
InvalidShape {
operation: String,
reason: String,
shape: Option<Vec<usize>>,
context: Option<ErrorContext>,
},
InvalidAxis {
operation: String,
axis: i32,
ndim: usize,
context: Option<ErrorContext>,
},
GradientNotEnabled {
operation: String,
suggestion: String,
context: Option<ErrorContext>,
},
InvalidArgument {
operation: String,
reason: String,
context: Option<ErrorContext>,
},
AllocationError {
operation: String,
details: String,
requested_bytes: Option<usize>,
available_bytes: Option<usize>,
context: Option<ErrorContext>,
},
UnsupportedOperation {
operation: String,
reason: String,
alternatives: Vec<String>,
context: Option<ErrorContext>,
},
GpuError {
operation: String,
details: String,
gpu_id: Option<usize>,
fallback_attempted: bool,
context: Option<ErrorContext>,
},
DeviceError {
operation: String,
details: String,
device: String,
context: Option<ErrorContext>,
},
ComputeError {
operation: String,
details: String,
retry_possible: bool,
context: Option<ErrorContext>,
},
BlasError {
operation: String,
details: String,
context: Option<ErrorContext>,
},
SerializationError {
operation: String,
details: String,
context: Option<ErrorContext>,
},
NotImplemented {
operation: String,
details: String,
planned_version: Option<String>,
context: Option<ErrorContext>,
},
InvalidOperation {
operation: String,
reason: String,
context: Option<ErrorContext>,
},
BenchmarkError {
operation: String,
details: String,
context: Option<ErrorContext>,
},
IoError {
operation: String,
details: String,
path: Option<String>,
context: Option<ErrorContext>,
},
NumericalError {
operation: String,
details: String,
suggestions: Vec<String>,
context: Option<ErrorContext>,
},
ResourceExhausted {
operation: String,
resource: String,
current_usage: Option<usize>,
limit: Option<usize>,
context: Option<ErrorContext>,
},
Timeout {
operation: String,
duration_ms: u64,
context: Option<ErrorContext>,
},
CacheError {
operation: String,
details: String,
recoverable: bool,
context: Option<ErrorContext>,
},
Other {
operation: String,
details: String,
context: Option<ErrorContext>,
},
}Expand description
Enhanced error handling with contextual information and recovery strategies
Variants§
ShapeMismatch
DeviceMismatch
UnsupportedDevice
InvalidShape
InvalidAxis
GradientNotEnabled
InvalidArgument
AllocationError
Fields
context: Option<ErrorContext>UnsupportedOperation
GpuError
Fields
context: Option<ErrorContext>DeviceError
ComputeError
BlasError
SerializationError
NotImplemented
Fields
context: Option<ErrorContext>InvalidOperation
BenchmarkError
IoError
NumericalError
ResourceExhausted
Fields
context: Option<ErrorContext>Timeout
CacheError
Other
Implementations§
Source§impl TensorError
impl TensorError
Sourcepub fn shape_mismatch(operation: &str, expected: &str, got: &str) -> TensorError
pub fn shape_mismatch(operation: &str, expected: &str, got: &str) -> TensorError
Create a shape mismatch error with context
Sourcepub fn device_mismatch(
operation: &str,
device1: &str,
device2: &str,
) -> TensorError
pub fn device_mismatch( operation: &str, device1: &str, device2: &str, ) -> TensorError
Create a device mismatch error with context
Sourcepub fn unsupported_device(
operation: &str,
device: &str,
fallback_available: bool,
) -> TensorError
pub fn unsupported_device( operation: &str, device: &str, fallback_available: bool, ) -> TensorError
Create an unsupported device error with fallback information
Sourcepub fn gpu_error(
operation: &str,
details: &str,
gpu_id: Option<usize>,
fallback_attempted: bool,
) -> TensorError
pub fn gpu_error( operation: &str, details: &str, gpu_id: Option<usize>, fallback_attempted: bool, ) -> TensorError
Create a GPU error with fallback information
Sourcepub fn allocation_error(
operation: &str,
details: &str,
requested: Option<usize>,
available: Option<usize>,
) -> TensorError
pub fn allocation_error( operation: &str, details: &str, requested: Option<usize>, available: Option<usize>, ) -> TensorError
Create an allocation error with memory information
Sourcepub fn numerical_error(
operation: &str,
details: &str,
suggestions: Vec<String>,
) -> TensorError
pub fn numerical_error( operation: &str, details: &str, suggestions: Vec<String>, ) -> TensorError
Create a numerical error with suggestions
Sourcepub fn invalid_argument(reason: String) -> TensorError
pub fn invalid_argument(reason: String) -> TensorError
Create an invalid argument error (for backward compatibility)
Sourcepub fn invalid_argument_op(operation: &str, reason: &str) -> TensorError
pub fn invalid_argument_op(operation: &str, reason: &str) -> TensorError
Create an invalid argument error with operation context
Sourcepub fn other(details: String) -> TensorError
pub fn other(details: String) -> TensorError
Create a generic “other” error (for backward compatibility)
Sourcepub fn other_op(operation: &str, details: &str) -> TensorError
pub fn other_op(operation: &str, details: &str) -> TensorError
Create a generic “other” error with operation context
Sourcepub fn allocation_error_simple(details: String) -> TensorError
pub fn allocation_error_simple(details: String) -> TensorError
Create an allocation error (for backward compatibility)
Sourcepub fn unsupported_operation_simple(reason: String) -> TensorError
pub fn unsupported_operation_simple(reason: String) -> TensorError
Create an unsupported operation error (for backward compatibility)
Sourcepub fn invalid_shape(operation: &str, expected: &str, got: &str) -> TensorError
pub fn invalid_shape(operation: &str, expected: &str, got: &str) -> TensorError
Create an invalid shape error with operation context
Sourcepub fn invalid_shape_simple(reason: String) -> TensorError
pub fn invalid_shape_simple(reason: String) -> TensorError
Create an invalid shape error (for backward compatibility)
Sourcepub fn device_error_simple(details: String) -> TensorError
pub fn device_error_simple(details: String) -> TensorError
Create a device error (for backward compatibility)
Sourcepub fn compute_error_simple(details: String) -> TensorError
pub fn compute_error_simple(details: String) -> TensorError
Create a compute error (for backward compatibility)
Sourcepub fn serialization_error_simple(details: String) -> TensorError
pub fn serialization_error_simple(details: String) -> TensorError
Create a serialization error (for backward compatibility)
Sourcepub fn not_implemented_simple(details: String) -> TensorError
pub fn not_implemented_simple(details: String) -> TensorError
Create a not implemented error (for backward compatibility)
Sourcepub fn invalid_operation_simple(reason: String) -> TensorError
pub fn invalid_operation_simple(reason: String) -> TensorError
Create an invalid operation error (for backward compatibility)
Sourcepub fn benchmark_error_simple(details: String) -> TensorError
pub fn benchmark_error_simple(details: String) -> TensorError
Create a benchmark error (for backward compatibility)
Sourcepub fn io_error_simple(details: String) -> TensorError
pub fn io_error_simple(details: String) -> TensorError
Create an IO error (for backward compatibility)
Sourcepub fn resource_exhausted_simple(resource: String) -> TensorError
pub fn resource_exhausted_simple(resource: String) -> TensorError
Create a resource exhausted error (for backward compatibility)
Sourcepub fn timeout_simple(duration_ms: u64) -> TensorError
pub fn timeout_simple(duration_ms: u64) -> TensorError
Create a timeout error (for backward compatibility)
Sourcepub fn with_context(self, context: ErrorContext) -> TensorError
pub fn with_context(self, context: ErrorContext) -> TensorError
Add context to an existing error
Sourcepub fn supports_fallback(&self) -> bool
pub fn supports_fallback(&self) -> bool
Check if this error supports fallback recovery
Sourcepub fn recovery_strategy(&self) -> RecoveryStrategy
pub fn recovery_strategy(&self) -> RecoveryStrategy
Get suggested recovery strategy
Trait Implementations§
Source§impl Clone for TensorError
impl Clone for TensorError
Source§fn clone(&self) -> TensorError
fn clone(&self) -> TensorError
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for TensorError
impl Debug for TensorError
Source§impl Display for TensorError
impl Display for TensorError
Source§impl Error for TensorError
impl Error for TensorError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<Error> for TensorError
Convert from std::fmt::Error to TensorError
impl From<Error> for TensorError
Convert from std::fmt::Error to TensorError
Source§fn from(err: Error) -> TensorError
fn from(err: Error) -> TensorError
Source§impl From<FederatedError> for TensorError
Convert a FederatedError into a TensorError for compatibility with
the rest of the TenfloweRS error hierarchy.
impl From<FederatedError> for TensorError
Convert a FederatedError into a TensorError for compatibility with
the rest of the TenfloweRS error hierarchy.
Source§fn from(e: FederatedError) -> TensorError
fn from(e: FederatedError) -> TensorError
Source§impl From<HdcError> for TensorError
impl From<HdcError> for TensorError
Source§fn from(e: HdcError) -> TensorError
fn from(e: HdcError) -> TensorError
Source§impl From<ShapeError> for TensorError
Convert from scirs2_core::ndarray::ShapeError to TensorError
impl From<ShapeError> for TensorError
Convert from scirs2_core::ndarray::ShapeError to TensorError
Source§fn from(err: ShapeError) -> TensorError
fn from(err: ShapeError) -> TensorError
Source§impl From<ValidationError> for TensorError
impl From<ValidationError> for TensorError
Source§fn from(err: ValidationError) -> TensorError
fn from(err: ValidationError) -> TensorError
Auto Trait Implementations§
impl Freeze for TensorError
impl RefUnwindSafe for TensorError
impl Send for TensorError
impl Sync for TensorError
impl Unpin for TensorError
impl UnsafeUnpin for TensorError
impl UnwindSafe for TensorError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
Source§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.