1use std::error::Error as StdError;
2use std::fmt;
3
4pub type Result<T> = std::result::Result<T, Error>;
6
7#[derive(Debug, Clone, PartialEq, Eq)]
9pub enum Error {
10 Config(String),
11 Layout(String),
12 Training(String),
13 Inference(String),
14 Io(String),
16 Serialization(String),
18 WeightsConfigMismatch(String),
20}
21
22impl fmt::Display for Error {
23 fn fmt(&self, formatter: &mut fmt::Formatter<'_>) -> fmt::Result {
24 match self {
25 Self::Config(message) => write!(formatter, "invalid configuration: {message}"),
26 Self::Layout(message) => write!(formatter, "layout error: {message}"),
27 Self::Training(message) => write!(formatter, "training error: {message}"),
28 Self::Inference(message) => write!(formatter, "inference error: {message}"),
29 Self::Io(message) => write!(formatter, "I/O error: {message}"),
30 Self::Serialization(message) => {
31 write!(formatter, "serialization error: {message}")
32 }
33 Self::WeightsConfigMismatch(message) => {
34 write!(formatter, "weights config mismatch: {message}")
35 }
36 }
37 }
38}
39
40impl StdError for Error {}