use thiserror::Error;
use cubecl::server::ServerError;
#[derive(Debug, Error)]
#[non_exhaustive]
pub enum CubeclUtilsErrors {
#[error(
"Kernel '{kernel}' requested a cube count of {requested:?}, but this device's limit is \
{limit:?}."
)]
CubeCountExceeded {
kernel: &'static str,
requested: (u32, u32, u32),
limit: (u32, u32, u32),
},
#[error(
"A grid of {total_cubes} cubes does not fit a 2D decomposition bounded by {max_dim} per \
dimension."
)]
GridTooLarge {
total_cubes: u32,
max_dim: u32,
},
#[error(
"A GPU buffer of {requested} bytes exceeds this device's per-binding limit of {limit} \
bytes."
)]
BindingTooLarge {
requested: u64,
limit: u64,
},
#[error(
"Kernel '{kernel}' needs {requested} bytes of shared memory, but this device offers only \
{available} bytes per workgroup."
)]
SharedMemoryExceeded {
kernel: &'static str,
requested: usize,
available: usize,
},
#[error("Error from the cubecl runtime: {0}")]
CubeClServerError(#[from] ServerError),
}