1use std::error::Error;
2use std::fmt;
3use std::fmt::Display;
4
5#[derive(Clone, Debug, PartialEq)]
7pub enum GemmError {
8 BatchSizeMismatch,
10 KSizeMismatch,
12 WrongBiasSize,
14 WrongQuantParamSize,
16 OutputSizeMismatch,
18 PackedDataKernelMismatch,
21 PackedDataBlockingMismatch,
24 BlockQuantizedInputNotSupported,
26 QuantBitsNotSupported,
28}
29
30impl Display for GemmError {
31 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
32 match self {
33 Self::BatchSizeMismatch => {
34 write!(fmt, "batches of `a` and `b` matrices must have same length")
35 }
36 Self::KSizeMismatch => {
37 write!(fmt, "columns of matrix `a` must match rows of matrix `b`")
38 }
39 Self::WrongBiasSize => write!(fmt, "bias vector length is incorrect"),
40 Self::WrongQuantParamSize => {
41 write!(fmt, "quantization parameter size does not match input")
42 }
43 Self::OutputSizeMismatch => write!(fmt, "output buffer has wrong length"),
44 Self::PackedDataKernelMismatch => {
45 write!(fmt, "matrix was packed with a different kernel")
46 }
47 Self::PackedDataBlockingMismatch => {
48 write!(fmt, "matrix was packed with a different blocking size")
49 }
50 Self::BlockQuantizedInputNotSupported => {
51 write!(fmt, "block-quantized inputs not supported for data type")
52 }
53 Self::QuantBitsNotSupported => {
54 write!(
55 fmt,
56 "quantized input has an unsupported number of bits per element"
57 )
58 }
59 }
60 }
61}
62
63impl Error for GemmError {}
64
65#[derive(Copy, Clone, Debug, PartialEq)]
67pub enum BlockQuantizedError {
68 UnsupportedBlockSize,
70 UnsupportedElementSize,
72}
73
74impl Display for BlockQuantizedError {
75 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
76 match self {
77 Self::UnsupportedBlockSize => write!(f, "block size is unsupported"),
78 Self::UnsupportedElementSize => write!(f, "unsupported bits-per-element"),
79 }
80 }
81}
82
83impl Error for BlockQuantizedError {}