Files
rustytorch/crates/production/rtx-onnx-codegen/src/error.rs
T
2026-03-04 00:08:42 +00:00

47 lines
1.3 KiB
Rust

//! Error types for ONNX code generation.
use thiserror::Error;
/// Result type for ONNX code generation operations.
pub type Result<T> = std::result::Result<T, Error>;
/// Errors that can occur during ONNX model import and code generation.
#[derive(Error, Debug)]
pub enum Error {
/// Failed to read the ONNX file.
#[error("Failed to read ONNX file: {0}")]
FileRead(#[from] std::io::Error),
/// Failed to parse the ONNX protobuf.
#[error("Failed to parse ONNX protobuf: {0}")]
ProtobufParse(#[from] prost::DecodeError),
/// Unsupported ONNX operator.
#[error("Unsupported ONNX operator: {0}")]
UnsupportedOperator(String),
/// Invalid ONNX model structure.
#[error("Invalid ONNX model: {0}")]
InvalidModel(String),
/// Missing required attribute.
#[error("Missing required attribute '{0}' for operator '{1}'")]
MissingAttribute(String, String),
/// Invalid attribute value.
#[error("Invalid attribute value for '{0}': {1}")]
InvalidAttribute(String, String),
/// Shape inference error.
#[error("Shape inference error: {0}")]
ShapeInference(String),
/// Code generation error.
#[error("Code generation error: {0}")]
CodeGen(String),
/// Unsupported data type.
#[error("Unsupported data type: {0}")]
UnsupportedDataType(i32),
}