pub enum Error {
Show 26 variants
Validation {
op: &'static str,
phase: ErrorPhase,
source: ValidationError,
},
MissingInput(String),
NonScalarGrad {
shape: Vec<usize>,
},
Unsupported {
op: &'static str,
phase: ErrorPhase,
message: String,
},
TensorRuntime(Error),
Extension {
op: &'static str,
phase: ErrorPhase,
family: &'static str,
kind: ErrorKind,
source: BoxError,
},
RuntimeState {
op: &'static str,
phase: ErrorPhase,
message: String,
},
RuntimeStateSource {
op: &'static str,
phase: ErrorPhase,
source: BoxError,
},
WithSuppressed {
primary: Box<Error>,
suppressed: Box<Error>,
},
EventDomain {
source: EventDomainError,
},
UnexpectedBinding {
binding_index: usize,
},
UnboundPlaceholder {
input_key: String,
},
GraphInputCountMismatch {
expected: usize,
actual: usize,
},
DuplicateBinding {
input_key: String,
},
PlaceholderDtypeMismatch {
expected: DType,
actual: DType,
},
PlaceholderShapeMismatch {
expected: Vec<usize>,
actual: Vec<usize>,
},
PlaceholderShapeBoundExceeded {
axis: usize,
bound: usize,
actual: usize,
},
PlaceholderRankMismatch {
expected: usize,
actual: usize,
},
ContextMismatch {
lhs: ContextId,
rhs: ContextId,
},
UnsupportedAdRule {
transform: &'static str,
op: String,
},
AdRuleSource {
transform: &'static str,
source: BoxError,
},
ShapeConstraintViolation {
family: &'static str,
instruction_index: Option<usize>,
relation: ShapeRelation,
lhs_expr: String,
rhs_expr: String,
lhs_value: usize,
rhs_value: usize,
},
ShapeConstraintEvaluation {
family: &'static str,
instruction_index: Option<usize>,
relation: ShapeRelation,
expression: String,
cause: ShapeConstraintEvalError,
},
SymbolicShapeConversion {
op: &'static str,
phase: ErrorPhase,
source: SymDimConversionError,
},
ShapeExpressionEvaluation {
expression: String,
cause: ShapeConstraintEvalError,
},
Internal(String),
}Expand description
Errors produced by einsum, eval, and other tenferro operations.
§Examples
use tenferro_runtime::error::{Error, ErrorPhase};
let err = Error::invalid_argument(
"einsum",
ErrorPhase::GraphBuild,
"subscripts",
"rank mismatch",
);Variants§
Validation
A shared tensor validation fact, annotated with the runtime phase.
Fields
phase: ErrorPhasePhase that discovered the validation fact.
source: ValidationErrorMachine-readable validation payload.
MissingInput(String)
A required input tensor is missing from the inputs map.
NonScalarGrad
Reverse-mode gradient requires a scalar output.
Unsupported
The operation is known not to support the requested input or configuration at the phase where it was requested.
Fields
phase: ErrorPhasePhase that established the unsupported combination.
TensorRuntime(Error)
Runtime tensor execution failed in the backend layer.
Extension
A typed extension-domain error crossed a runtime registry boundary.
Fields
phase: ErrorPhasePhase that discovered the extension failure.
RuntimeState
Executor, cache, registry, or device state is unavailable or invalid.
Fields
phase: ErrorPhasePhase that discovered the invalid state.
RuntimeStateSource
A runtime-state failure retaining a typed source.
Fields
phase: ErrorPhasePhase that discovered the invalid state.
WithSuppressed
A primary error with a second typed error retained as suppressed metadata.
The standard error source chain follows primary. The suppressed
error is intentionally exposed through Error::suppressed because
StdError::source can represent only one
source without losing the primary error’s semantics.
Fields
EventDomain
A runtime event-domain provenance or admission contract failed.
Fields
source: EventDomainErrorStructured event-domain failure with expected/actual provenance.
UnexpectedBinding
A TracedTensor supplied as a compiled-graph input binding is not a
placeholder (has attached data).
UnboundPlaceholder
A placeholder appearing in the graph has no binding supplied.
GraphInputCountMismatch
The number of ordered tensors supplied to a compiled graph is invalid.
DuplicateBinding
The same placeholder was bound more than once in the bindings slice.
PlaceholderDtypeMismatch
A binding tensor’s dtype does not match the placeholder’s dtype.
PlaceholderShapeMismatch
A binding tensor’s shape does not match an input_concrete_shape
placeholder’s fixed shape.
PlaceholderShapeBoundExceeded
A binding tensor dimension exceeds a semantic input’s declared bound.
Fields
PlaceholderRankMismatch
A binding tensor’s rank does not match an input_symbolic_shape
placeholder’s declared rank.
ContextMismatch
Operation attempted to mix tensors from different eager contexts.
UnsupportedAdRule
An AD transform requires a primitive or extension rule that is not registered for the requested operation.
Fields
AdRuleSource
A typed AD rule source that crossed an external message-only callback.
Fields
ShapeConstraintViolation
A symbolic extension shape equality evaluated to unequal dimensions.
Fields
relation: ShapeRelationShape relation that failed.
ShapeConstraintEvaluation
A symbolic extension shape expression could not be evaluated safely.
Fields
relation: ShapeRelationShape relation whose expression failed.
cause: ShapeConstraintEvalErrorTyped evaluation failure.
SymbolicShapeConversion
A symbolic dimension could not be converted into the graph’s local dimension-expression vocabulary.
Fields
phase: ErrorPhasePhase that discovered the invalid symbolic reference.
source: SymDimConversionErrorTyped symbolic-dimension conversion failure.
ShapeExpressionEvaluation
A runtime dimension expression could not be evaluated for concrete input shapes.
Fields
cause: ShapeConstraintEvalErrorTyped evaluation failure.
Internal(String)
An unexpected internal error.
Implementations§
Source§impl Error
impl Error
Sourcepub fn validation(
op: &'static str,
phase: ErrorPhase,
source: ValidationError,
) -> Self
pub fn validation( op: &'static str, phase: ErrorPhase, source: ValidationError, ) -> Self
Wrap a shared validation payload with its operation and discovery phase.
§Errors
This constructor does not fail; callers receive the returned
Error value and can inspect its Error::kind and
Error::phase.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::{ErrorKind, ShapeMismatch, ValidationKind};
let error = Error::validation(
"reshape",
ErrorPhase::GraphBuild,
ShapeMismatch::ReshapeElementCount { from: 2, to: 3 }.into(),
);
assert_eq!(
error.kind(),
ErrorKind::Validation(ValidationKind::ShapeMismatch)
);
assert_eq!(error.phase(), Some(ErrorPhase::GraphBuild));Sourcepub fn invalid_argument(
op: &'static str,
phase: ErrorPhase,
argument: &'static str,
message: impl Into<String>,
) -> Self
pub fn invalid_argument( op: &'static str, phase: ErrorPhase, argument: &'static str, message: impl Into<String>, ) -> Self
Construct a validation error for a caller-controlled argument whose failure does not have a more specific shared payload.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
let error = Error::invalid_argument(
"broadcast_in_dim",
ErrorPhase::GraphBuild,
"dims",
"dimension mapping has the wrong length",
);
assert!(matches!(error, Error::Validation { .. }));Sourcepub fn dtype_mismatch(
op: &'static str,
phase: ErrorPhase,
expected: DType,
actual: DType,
) -> Self
pub fn dtype_mismatch( op: &'static str, phase: ErrorPhase, expected: DType, actual: DType, ) -> Self
Construct a dtype-mismatch validation error using the runtime dtype vocabulary.
§Examples
use tenferro_runtime::{DType, Error, ErrorPhase};
use tenferro_tensor::{ErrorKind, ValidationKind};
let error = Error::dtype_mismatch(
"add",
ErrorPhase::GraphBuild,
DType::F32,
DType::F64,
);
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::DTypeMismatch));Sourcepub fn extension<E>(
op: &'static str,
phase: ErrorPhase,
family: &'static str,
kind: ErrorKind,
source: E,
) -> Self
pub fn extension<E>( op: &'static str, phase: ErrorPhase, family: &'static str, kind: ErrorKind, source: E, ) -> Self
Preserve a typed extension-domain source at the runtime boundary.
§Examples
use std::error::Error as _;
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::ErrorKind;
let source = std::io::Error::new(std::io::ErrorKind::Other, "extension failed");
let error = Error::extension(
"einsum",
ErrorPhase::GraphBuild,
"example.extension.v1",
ErrorKind::RuntimeState,
source,
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);
assert!(error.source().is_some());Sourcepub fn runtime_state(
op: &'static str,
phase: ErrorPhase,
message: impl Into<String>,
) -> Self
pub fn runtime_state( op: &'static str, phase: ErrorPhase, message: impl Into<String>, ) -> Self
Construct a runtime-state failure for an unavailable or invalid executor, cache, registry, or device state.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::ErrorKind;
let error = Error::runtime_state(
"executor",
ErrorPhase::Execution,
"the executor is not initialized",
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);Sourcepub fn runtime_state_source<E>(
op: &'static str,
phase: ErrorPhase,
source: E,
) -> Self
pub fn runtime_state_source<E>( op: &'static str, phase: ErrorPhase, source: E, ) -> Self
Preserve a typed source for an unavailable or invalid runtime state.
§Examples
use std::error::Error as _;
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::ErrorKind;
let error = Error::runtime_state_source(
"metadata",
ErrorPhase::Compile,
std::io::Error::other("registry lock poisoned"),
);
assert_eq!(error.kind(), ErrorKind::RuntimeState);
assert!(error.source().is_some());Sourcepub fn with_suppressed(primary: Self, suppressed: Self) -> Self
pub fn with_suppressed(primary: Self, suppressed: Self) -> Self
Retain a typed secondary error while preserving the primary error’s classification and standard source chain.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
let error = Error::with_suppressed(
Error::unsupported("backend", ErrorPhase::Execution, "primary"),
Error::runtime_state("runtime", ErrorPhase::Execution, "suppressed"),
);
assert!(error.primary().is_some());
assert!(error.suppressed().is_some());Sourcepub fn primary(&self) -> Option<&Self>
pub fn primary(&self) -> Option<&Self>
Return the primary error when this value is a suppressed-error aggregate.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
let error = Error::with_suppressed(
Error::unsupported("backend", ErrorPhase::Execution, "primary"),
Error::runtime_state("runtime", ErrorPhase::Execution, "suppressed"),
);
assert_eq!(error.primary().unwrap().phase(), Some(ErrorPhase::Execution));Sourcepub fn suppressed(&self) -> Option<&Self>
pub fn suppressed(&self) -> Option<&Self>
Return the typed suppressed error when this value is an aggregate.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
let error = Error::with_suppressed(
Error::unsupported("backend", ErrorPhase::Execution, "primary"),
Error::runtime_state("runtime", ErrorPhase::Execution, "suppressed"),
);
assert_eq!(error.suppressed().unwrap().phase(), Some(ErrorPhase::Execution));Sourcepub fn ad_rule_source<E>(transform: &'static str, source: E) -> Self
pub fn ad_rule_source<E>(transform: &'static str, source: E) -> Self
Preserve a typed source returned by an AD rule through a callback protocol that can carry only a rendered message.
§Examples
use std::error::Error as _;
use tenferro_runtime::Error;
let error = Error::ad_rule_source(
"jvp",
std::io::Error::other("shape metadata missing"),
);
assert!(error.source().is_some());Sourcepub fn unsupported(
op: &'static str,
phase: ErrorPhase,
message: impl Into<String>,
) -> Self
pub fn unsupported( op: &'static str, phase: ErrorPhase, message: impl Into<String>, ) -> Self
Construct an operation-level unsupported error with an explicit discovery phase.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::ErrorKind;
let error = Error::unsupported(
"compare",
ErrorPhase::Compile,
"complex values have no total order",
);
assert_eq!(error.kind(), ErrorKind::Unsupported);
assert_eq!(error.phase(), Some(ErrorPhase::Compile));Sourcepub fn kind(&self) -> ErrorKind
pub fn kind(&self) -> ErrorKind
Return the stable coarse classification of this runtime failure.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::{ErrorKind, ValidationError, ValidationKind};
let error = Error::validation(
"transpose",
ErrorPhase::GraphBuild,
ValidationError::AxisOutOfBounds { axis: 2, rank: 2 },
);
assert_eq!(error.kind(), ErrorKind::Validation(ValidationKind::AxisOutOfBounds));Sourcepub fn phase(&self) -> Option<ErrorPhase>
pub fn phase(&self) -> Option<ErrorPhase>
Return the discovery phase when this error has one.
§Examples
use tenferro_runtime::{Error, ErrorPhase};
use tenferro_tensor::ValidationError;
let error = Error::validation(
"reshape",
ErrorPhase::Compile,
ValidationError::RankMismatch { expected: 2, actual: 1 },
);
assert_eq!(error.phase(), Some(ErrorPhase::Compile));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()
Source§impl From<EventDomainError> for Error
impl From<EventDomainError> for Error
Source§fn from(source: EventDomainError) -> Self
fn from(source: EventDomainError) -> Self
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