1use thiserror::Error;
4
5#[derive(Error, Debug)]
7pub enum HiveGpuError {
8 #[error("Invalid dimension: expected {expected}, got {got}")]
10 InvalidDimension { expected: usize, got: usize },
11
12 #[error("Dimension mismatch: expected {expected}, got {actual}")]
14 DimensionMismatch { expected: usize, actual: usize },
15
16 #[error("VRAM limit exceeded: requested {requested}, limit {limit}")]
18 VramLimitExceeded { requested: usize, limit: usize },
19
20 #[error("GPU operation failed: {0}")]
22 GpuOperationFailed(String),
23
24 #[error("No GPU device available")]
26 NoDeviceAvailable,
27
28 #[error("Buffer allocation failed: {0}")]
30 BufferAllocationFailed(String),
31
32 #[error("Device initialization failed: {0}")]
34 DeviceInitializationFailed(String),
35
36 #[error("Shader compilation failed: {0}")]
38 ShaderCompilationFailed(String),
39
40 #[error("Memory allocation failed: {0}")]
42 MemoryAllocationFailed(String),
43
44 #[error("Search operation failed: {0}")]
46 SearchFailed(String),
47
48 #[error("Vector not found: {0}")]
50 VectorNotFound(String),
51
52 #[error("Invalid configuration: {0}")]
54 InvalidConfiguration(String),
55
56 #[error("CUDA error: {0}")]
58 CudaError(String),
59
60 #[error("cuBLAS error: {0}")]
62 CublasError(String),
63
64 #[error("HIP error: {0}")]
66 HipError(String),
67
68 #[error("rocBLAS error: {0}")]
70 RocblasError(String),
71
72 #[error("ROCm error: {0}")]
74 RocmError(String),
75
76 #[error("Vulkan error: {0}")]
79 VulkanError(String),
80
81 #[error("Intel backend error: {0}")]
83 IntelError(String),
84
85 #[error("SPIR-V compile error: {0}")]
87 SpirvCompileError(String),
88
89 #[error("Internal error: {0}")]
91 InternalError(String),
92
93 #[error("IO error: {0}")]
95 IoError(#[from] std::io::Error),
96
97 #[error("JSON error: {0}")]
99 JsonError(#[from] serde_json::Error),
100
101 #[error("{0}")]
103 Other(String),
104}
105
106pub type Result<T> = std::result::Result<T, HiveGpuError>;