1use core::fmt;
2
3#[derive(Debug, PartialEq, Eq, Clone, Hash)]
4pub enum ReduceError {
5 PlanesUnavailable,
7 CubeCountTooLarge,
9 ImprecisePlaneDim,
11 InvalidAxis { axis: usize, rank: usize },
13 MismatchShape {
15 expected_shape: Vec<usize>,
16 output_shape: Vec<usize>,
17 },
18}
19
20impl fmt::Display for ReduceError {
21 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
22 match self {
23 Self::PlanesUnavailable => write!(f, "Trying to launch a kernel using plane instructions, but there are not supported by the hardware."),
24 Self::CubeCountTooLarge => write!(f, "The cube count is larger than the max supported."),
25 Self::ImprecisePlaneDim => write!(f, "Trying to launch a kernel using plane instructions, but the min and max plane dimensions are different."),
26 Self::InvalidAxis{axis, rank} => write!(f, "The provided axis ({axis}) must be smaller than the input tensor rank ({rank})."),
27 Self::MismatchShape { expected_shape, output_shape } => {
28 write!(f, "The output shape (currently {output_shape:?}) should be {expected_shape:?}.")
29 }
30 }
31 }
32}
33
34impl std::error::Error for ReduceError {}