1use cubecl::{ir::ElemType, server::LaunchError};
2use thiserror::Error;
3
4#[derive(Error, Debug, Clone)]
5pub enum ReduceError {
7 #[error(
9 "Trying to launch a kernel using plane instructions, but there are not supported by the hardware."
10 )]
11 PlanesUnavailable,
12 #[error("The cube count is larger than the max supported.")]
14 CubeCountTooLarge,
15
16 #[error("A generic validation error: {details}")]
18 Validation { details: &'static str },
19
20 #[error(
22 "Trying to launch a kernel using plane instructions, but the min and max plane dimensions are different."
23 )]
24 ImprecisePlaneDim,
25 #[error("The provided axis ({axis}) must be smaller than the input tensor rank ({rank}).")]
27 InvalidAxis { axis: usize, rank: usize },
28 #[error(
30 "The input reduce axis length (currently {axis_length:?}) should be at least k ({k:?})."
31 )]
32 ReduceAxisTooSmall { axis_length: usize, k: usize },
33 #[error("The output shape (currently {output_shape:?}) should be {expected_shape:?}.")]
35 MismatchOutputShape {
36 expected_shape: Vec<usize>,
37 output_shape: Vec<usize>,
38 },
39 #[error(
41 "The indices shape (currently {indices_shape:?}) should match the values shape ({values_shape:?})."
42 )]
43 MismatchIndicesShape {
44 values_shape: Vec<usize>,
45 indices_shape: Vec<usize>,
46 },
47 #[error(
49 "The indices strides (currently {indices_strides:?}) should match the values strides ({values_strides:?})."
50 )]
51 MismatchIndicesStrides {
52 values_strides: Vec<usize>,
53 indices_strides: Vec<usize>,
54 },
55 #[error(
57 "The operation {operation} has no index to report; reduce_with_indices only supports TopK, ArgTopK, Max, ArgMax, Min and ArgMin."
58 )]
59 IndicesUnsupported { operation: &'static str },
60
61 #[error("Atomic add not supported by the client for {0}")]
63 MissingAtomicAdd(ElemType),
64
65 #[error(
68 "Reduce blueprint requires {requested} bytes of shared memory, but only {available} bytes are available on the device."
69 )]
70 SharedMemoryOverflow { requested: usize, available: usize },
71
72 #[error("An error happened during launch\nCaused by:\n {0}")]
74 Launch(LaunchError),
75}