Skip to main content

vsa_optim_rs/
error.rs

1//! Error types for VSA training optimization.
2
3use thiserror::Error;
4
5/// Result type alias for VSA optimization operations.
6pub type Result<T> = std::result::Result<T, OptimError>;
7
8/// Errors that can occur during VSA optimization operations.
9#[derive(Debug, Error)]
10pub enum OptimError {
11    /// Invalid configuration parameter.
12    #[error("invalid configuration: {0}")]
13    InvalidConfig(String),
14
15    /// Shape mismatch in tensor operations.
16    #[error("shape mismatch: expected {expected:?}, got {actual:?}")]
17    ShapeMismatch {
18        /// Expected shape.
19        expected: Vec<usize>,
20        /// Actual shape.
21        actual: Vec<usize>,
22    },
23
24    /// Dimension mismatch.
25    #[error("dimension mismatch: expected {expected}, got {actual}")]
26    DimensionMismatch {
27        /// Expected dimension.
28        expected: usize,
29        /// Actual dimension.
30        actual: usize,
31    },
32
33    /// Empty input where non-empty was required.
34    #[error("empty input: {0}")]
35    EmptyInput(String),
36
37    /// Compression error.
38    #[error("compression error: {0}")]
39    Compression(String),
40
41    /// Prediction error.
42    #[error("prediction error: {0}")]
43    Prediction(String),
44
45    /// Candle tensor operation error.
46    #[error("tensor error: {0}")]
47    Tensor(#[from] candle_core::Error),
48
49    /// Ternary operation error.
50    #[error("ternary error: {0}")]
51    Ternary(#[from] trit_vsa::TernaryError),
52}