#[derive(Debug, thiserror::Error)]
pub enum TensorError {
#[error("shape mismatch: expected {expected:?}, got {got:?}")]
ShapeMismatch {
expected: Vec<usize>,
got: Vec<usize>,
},
#[error("data length {len} does not match shape {shape:?} (product = {product})")]
DataLengthMismatch {
len: usize,
shape: Vec<usize>,
product: usize,
},
#[error("invalid einsum subscript: {0}")]
InvalidSubscript(String),
#[error(
"contracted dimension mismatch: index '{index}' has size {size_a} in A but {size_b} in B"
)]
ContractionDimensionMismatch {
index: char,
size_a: usize,
size_b: usize,
},
}