use thiserror::Error; pub type Result = std::result::Result; #[derive(Debug, Error)] pub enum Error { #[error("io error: {0}")] Io(#[from] std::io::Error), #[error("json error: {0}")] Json(#[from] serde_json::Error), #[error("checkpoint format error: {0}")] Checkpoint(String), #[error("model error: {0}")] Model(String), #[error("shape mismatch: expected {expected:?}, got {got:?} for tensor {name}")] Shape { name: String, expected: Vec, got: Vec, }, #[error("missing tensor {0} in checkpoint")] MissingTensor(String), #[error("unsupported dtype {0}")] Dtype(String), #[error("shape error: {0}")] Shapes(String), } impl From for Error { fn from(e: ndarray::ShapeError) -> Self { Error::Shapes(e.to_string()) } }