#[non_exhaustive]pub enum Error {
Show 13 variants
Validation {
op: &'static str,
source: ValidationError,
},
UnsupportedDTypeConversion {
op: &'static str,
from: DType,
to: DType,
message: String,
},
UnsupportedDType {
op: &'static str,
dtype: DType,
message: String,
},
Unsupported {
op: &'static str,
message: String,
},
BackendFailure {
op: &'static str,
message: String,
},
BackendSource {
op: &'static str,
source: BoxError,
},
IoSource {
op: &'static str,
source: BoxError,
},
RuntimeState {
op: &'static str,
message: String,
},
RuntimeStateSource {
op: &'static str,
source: BoxError,
},
HostAccess {
op: &'static str,
source: HostAccessError,
},
Extension {
op: &'static str,
family: &'static str,
kind: ErrorKind,
source: BoxError,
},
MissingValue {
slot: usize,
},
Internal(String),
}Expand description
Runtime failures produced by tensor execution backends and helpers.
Validation failures retain the shared tensor-core payload as a typed source.
Backend and extension failures retain opaque typed sources when one exists;
text-only vendor failures use Error::BackendFailure.
§Examples
let error = tenferro_tensor::Error::rank_mismatch("reshape", 2, 1);
assert!(matches!(
error,
tenferro_tensor::Error::Validation { op: "reshape", .. }
));Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Validation
UnsupportedDTypeConversion
UnsupportedDType
Unsupported
BackendFailure
BackendSource
IoSource
RuntimeState
RuntimeStateSource
HostAccess
Extension
MissingValue
Internal(String)
Implementations§
Source§impl Error
impl Error
Sourcepub fn shape_mismatch(
op: &'static str,
lhs: impl Into<Vec<usize>>,
rhs: impl Into<Vec<usize>>,
) -> Self
pub fn shape_mismatch( op: &'static str, lhs: impl Into<Vec<usize>>, rhs: impl Into<Vec<usize>>, ) -> Self
Construct an incompatible-shapes validation error.
§Examples
use tenferro_tensor::Error;
let error = Error::shape_mismatch("add", [2, 3], [2, 4]);
assert!(matches!(error, Error::Validation { .. }));Sourcepub fn rank_mismatch(op: &'static str, expected: usize, actual: usize) -> Self
pub fn rank_mismatch(op: &'static str, expected: usize, actual: usize) -> Self
Construct a rank-mismatch validation error.
§Examples
use tenferro_tensor::Error;
let error = Error::rank_mismatch("transpose", 2, 3);
assert!(matches!(error, Error::Validation { .. }));Sourcepub fn axis_out_of_bounds(op: &'static str, axis: usize, rank: usize) -> Self
pub fn axis_out_of_bounds(op: &'static str, axis: usize, rank: usize) -> Self
Construct an axis-out-of-bounds validation error.
§Examples
use tenferro_tensor::Error;
let error = Error::axis_out_of_bounds("sum", 2, 2);
assert!(matches!(error, Error::Validation { .. }));Sourcepub fn duplicate_axis(op: &'static str, axis: usize, role: &'static str) -> Self
pub fn duplicate_axis(op: &'static str, axis: usize, role: &'static str) -> Self
Construct a duplicate-axis validation error.
§Examples
use tenferro_tensor::Error;
let error = Error::duplicate_axis("transpose", 1, "permutation");
assert!(matches!(error, Error::Validation { .. }));Sourcepub fn dtype_mismatch(op: &'static str, expected: DType, actual: DType) -> Self
pub fn dtype_mismatch(op: &'static str, expected: DType, actual: DType) -> Self
Construct a dtype-mismatch validation error.
§Examples
use tenferro_tensor::{DType, Error};
let error = Error::dtype_mismatch("add", DType::F32, DType::F64);
assert!(matches!(error, Error::Validation { .. }));Sourcepub fn validation(op: &'static str, source: ValidationError) -> Self
pub fn validation(op: &'static str, source: ValidationError) -> Self
Wrap shared tensor validation with the operation that requested it.
§Examples
use tenferro_tensor::{Error, ValidationError};
let error = Error::validation(
"transpose",
ValidationError::AxisOutOfBounds { axis: 2, rank: 2 },
);
assert!(matches!(error, Error::Validation { op: "transpose", .. }));Sourcepub fn invalid_argument(
op: &'static str,
argument: &'static str,
message: impl Into<String>,
) -> Self
pub fn invalid_argument( op: &'static str, argument: &'static str, message: impl Into<String>, ) -> Self
Construct a structured invalid-argument validation error.
§Examples
use tenferro_tensor::{Error, ErrorKind, ValidationKind};
let error = Error::invalid_argument("slice", "step", "must be non-zero");
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::InvalidArgument));Sourcepub fn unsupported_dtype_conversion(
op: &'static str,
from: DType,
to: DType,
message: impl Into<String>,
) -> Self
pub fn unsupported_dtype_conversion( op: &'static str, from: DType, to: DType, message: impl Into<String>, ) -> Self
Construct an unsupported dtype conversion error.
§Examples
let error = tenferro_tensor::Error::unsupported_dtype_conversion(
"convert",
tenferro_tensor::DType::F64,
tenferro_tensor::DType::I32,
"lossy conversion is disabled",
);
assert!(matches!(
error,
tenferro_tensor::Error::UnsupportedDTypeConversion { .. }
));Sourcepub fn unsupported_dtype(
op: &'static str,
dtype: DType,
message: impl Into<String>,
) -> Self
pub fn unsupported_dtype( op: &'static str, dtype: DType, message: impl Into<String>, ) -> Self
Construct an operation-level unsupported-dtype error.
This is for an operation that cannot run for the supplied dtype. It is
deliberately distinct from Error::unsupported_dtype_conversion,
which is reserved for an actual from-dtype to to-dtype conversion.
§Examples
let error = tenferro_tensor::Error::unsupported_dtype(
"exp",
tenferro_tensor::DType::I64,
"integer exponentials are not implemented",
);
assert!(matches!(
error,
tenferro_tensor::Error::UnsupportedDType {
op: "exp",
dtype: tenferro_tensor::DType::I64,
..
}
));Sourcepub fn unsupported(op: &'static str, message: impl Into<String>) -> Self
pub fn unsupported(op: &'static str, message: impl Into<String>) -> Self
Construct a structured unsupported-operation error.
Use this for an operation or execution surface that is not implemented
by the selected backend. Dtype conversion failures use
Error::unsupported_dtype_conversion instead, and operation-specific
typed reasons should use Error::extension with ErrorKind::Unsupported.
§Examples
let error = tenferro_tensor::Error::unsupported(
"full_piv_lu",
"backend has no implementation",
);
assert!(matches!(
error,
tenferro_tensor::Error::Unsupported { op: "full_piv_lu", .. }
));Sourcepub fn backend_failure(op: &'static str, message: impl Into<String>) -> Self
pub fn backend_failure(op: &'static str, message: impl Into<String>) -> Self
Construct a text-only backend failure.
Use Error::backend_source when a typed source is available.
§Examples
let error = tenferro_tensor::Error::backend_failure(
"matmul",
"backend rejected launch",
);
assert!(matches!(
error,
tenferro_tensor::Error::BackendFailure { op: "matmul", .. }
));Sourcepub fn backend_source<E>(op: &'static str, source: E) -> Self
pub fn backend_source<E>(op: &'static str, source: E) -> Self
Construct a backend failure while preserving its typed source.
§Examples
let error = tenferro_tensor::Error::backend_source(
"load",
std::io::Error::other("read failed"),
);
assert!(std::error::Error::source(&error).is_some());Sourcepub fn io_source<E>(op: &'static str, source: E) -> Self
pub fn io_source<E>(op: &'static str, source: E) -> Self
Construct an I/O failure while preserving its typed source.
I/O errors are intentionally separate from backend failures: callers
can classify them as ErrorKind::Io without parsing a message.
§Examples
use tenferro_tensor::{Error, ErrorKind};
let error = Error::io_source("load", std::io::Error::other("read failed"));
assert_eq!(error.kind(), ErrorKind::Io);
assert!(std::error::Error::source(&error).is_some());Sourcepub fn runtime_state(op: &'static str, message: impl Into<String>) -> Self
pub fn runtime_state(op: &'static str, message: impl Into<String>) -> Self
Construct a runtime-state failure when no typed source exists.
Use this for missing, uninitialized, or invalid execution state. It is
distinct from Error::backend_failure, which is reserved for
vendor/backend status text.
§Examples
use tenferro_tensor::{Error, ErrorKind};
let error = Error::runtime_state("execute", "backend session is not initialized");
assert_eq!(error.kind(), ErrorKind::RuntimeState);Sourcepub fn runtime_state_source<E>(op: &'static str, source: E) -> Self
pub fn runtime_state_source<E>(op: &'static str, source: E) -> Self
Construct a runtime-state failure while preserving a typed source.
§Examples
use tenferro_tensor::{Error, ErrorKind};
let error = Error::runtime_state_source(
"execute",
std::io::Error::other("executor lock poisoned"),
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);
assert!(std::error::Error::source(&error).is_some());Sourcepub fn extension<E>(
op: &'static str,
family: &'static str,
kind: ErrorKind,
source: E,
) -> Self
pub fn extension<E>( op: &'static str, family: &'static str, kind: ErrorKind, source: E, ) -> Self
Construct an extension failure while preserving its typed source and coarse classification.
§Examples
use std::error::Error as _;
use tenferro_tensor::{Error, ErrorKind};
let error = Error::extension(
"einsum",
"einsum",
ErrorKind::Internal,
std::io::Error::other("planner failed"),
);
assert!(error.source().is_some());Sourcepub fn host_access(op: &'static str, source: HostAccessError) -> Self
pub fn host_access(op: &'static str, source: HostAccessError) -> Self
Preserve a typed guarded-host-access failure.
§Examples
use tenferro_tensor::{Error, HostAccessError};
let error = Error::host_access(
"map",
HostAccessError::Unsupported { backend: "opaque" },
);
assert!(matches!(error, Error::HostAccess { .. }));Sourcepub fn kind(&self) -> ErrorKind
pub fn kind(&self) -> ErrorKind
Return the stable coarse classification for this tensor failure.
§Examples
use tenferro_tensor::{Error, ErrorKind, ValidationError, ValidationKind};
use tenferro_tensor::core::DType;
let error = Error::validation(
"add",
ValidationError::DTypeMismatch {
expected: DType::F32,
actual: DType::F64,
},
);
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::DTypeMismatch));Trait Implementations§
Source§impl Error for Error
impl Error for Error
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()
Auto Trait Implementations§
impl Freeze for Error
impl !RefUnwindSafe for Error
impl Send for Error
impl Sync for Error
impl Unpin for Error
impl UnsafeUnpin for Error
impl !UnwindSafe for Error
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> 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 more