1use thiserror::Error;
4
5use crate::node::NodeId;
6
7pub type GraphResult<T> = Result<T, GraphError>;
9
10#[derive(Debug, Error)]
12pub enum GraphError {
13 #[error("node {0:?} not found in graph")]
15 NodeNotFound(NodeId),
16
17 #[error("adding edge from {from:?} to {to:?} would create a cycle")]
19 CycleDetected { from: NodeId, to: NodeId },
20
21 #[error("graph is empty")]
23 EmptyGraph,
24
25 #[error("buffer shape mismatch at node {node:?}: expected {expected} bytes, got {got} bytes")]
27 BufferSizeMismatch {
28 node: NodeId,
29 expected: usize,
30 got: usize,
31 },
32
33 #[error("nodes {a:?} and {b:?} cannot be fused: {reason}")]
35 FusionNotPossible {
36 a: NodeId,
37 b: NodeId,
38 reason: &'static str,
39 },
40
41 #[error("memory planning failed: {0}")]
43 MemoryPlanningFailed(String),
44
45 #[error("stream partitioning failed: {0}")]
47 StreamPartitioningFailed(String),
48
49 #[error("invalid execution plan: {0}")]
51 InvalidPlan(String),
52
53 #[error("PTX codegen failed for fusion group {group}: {reason}")]
55 PtxCodegenFailed { group: usize, reason: String },
56
57 #[error("internal graph error: {0}")]
59 Internal(String),
60}