1#[derive(Debug, thiserror::Error)]
5pub enum TensorError {
6 #[error("shape mismatch: expected {expected:?}, got {got:?}")]
8 ShapeMismatch {
9 expected: Vec<usize>,
11 got: Vec<usize>,
13 },
14
15 #[error("data length {len} does not match shape {shape:?} (product = {product})")]
17 DataLengthMismatch {
18 len: usize,
20 shape: Vec<usize>,
22 product: usize,
24 },
25
26 #[error("invalid einsum subscript: {0}")]
28 InvalidSubscript(String),
29
30 #[error(
32 "contracted dimension mismatch: index '{index}' has size {size_a} in A but {size_b} in B"
33 )]
34 ContractionDimensionMismatch {
35 index: char,
37 size_a: usize,
39 size_b: usize,
41 },
42}