Skip to main content

singe_kernel/
error.rs

1use thiserror::Error;
2
3#[derive(Debug, Error)]
4pub enum Error {
5    #[error("invalid length")]
6    InvalidLength,
7    #[error("length mismatch")]
8    LengthMismatch,
9    #[error("length mismatch for {name}: expected {expected}, actual {actual}")]
10    LengthMismatchFor {
11        name: String,
12        expected: usize,
13        actual: usize,
14    },
15    #[error("length too short for {name}: minimum {minimum}, actual {actual}")]
16    LengthTooShort {
17        name: String,
18        minimum: usize,
19        actual: usize,
20    },
21    #[error("rank reach mismatch for {name}: rank {rank}, required {required}, actual {actual}")]
22    RankReachMismatch {
23        name: String,
24        rank: usize,
25        required: usize,
26        actual: usize,
27    },
28    #[error("length exceeds i32")]
29    LengthExceedsI32,
30    #[error("null pointer")]
31    NullPointer,
32    #[error("size overflow")]
33    SizeOverflow,
34    #[error("unsupported fft size for {transform}: n = {n}")]
35    UnsupportedFftSize { transform: String, n: usize },
36    #[error("unsupported axis for {op}: axis = {axis}")]
37    UnsupportedAxis { op: String, axis: usize },
38    #[error("unsupported width for {op}: width = {width}")]
39    UnsupportedWidth { op: String, width: usize },
40    #[error("unsupported kernel size for {op}: kernel_size = {kernel_size}")]
41    UnsupportedKernelSize { op: String, kernel_size: usize },
42    #[error("unsupported block count for {op}: blocks = {blocks}")]
43    UnsupportedBlockCount { op: String, blocks: usize },
44    #[error("missing parameter for {op}: {parameter}")]
45    MissingParameter { op: String, parameter: String },
46    #[error("unsupported parameter for {op}: {parameter} = {value}")]
47    UnsupportedParameter {
48        op: String,
49        parameter: String,
50        value: usize,
51    },
52    #[error("unsupported configuration for {op}: {reason}")]
53    UnsupportedConfiguration { op: String, reason: String },
54
55    #[cfg(feature = "cuda_13_3")]
56    #[error("cuda error: {0}")]
57    Cuda(#[from] singe_cuda::error::Error),
58
59    #[cfg(feature = "cutile")]
60    #[error("cutile error: {0}")]
61    Cutile(#[from] cutile::error::Error),
62    #[cfg(feature = "cutile")]
63    #[error("cutile device error: {0}")]
64    CutileDevice(#[from] cutile::prelude::DeviceError),
65    #[cfg(feature = "cutile")]
66    #[error("cutile driver error: {0}")]
67    CutileDriver(#[from] cuda_core::DriverError),
68}
69
70pub type Result<T> = std::result::Result<T, Error>;