use std::error::Error;
use std::fmt;
use std::fmt::Display;
#[derive(Clone, Debug, PartialEq)]
pub enum GemmError {
BatchSizeMismatch,
KSizeMismatch,
WrongBiasSize,
WrongQuantParamSize,
OutputSizeMismatch,
PackedDataKernelMismatch,
PackedDataBlockingMismatch,
BlockQuantizedInputNotSupported,
QuantBitsNotSupported,
}
impl Display for GemmError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::BatchSizeMismatch => {
write!(fmt, "batches of `a` and `b` matrices must have same length")
}
Self::KSizeMismatch => {
write!(fmt, "columns of matrix `a` must match rows of matrix `b`")
}
Self::WrongBiasSize => write!(fmt, "bias vector length is incorrect"),
Self::WrongQuantParamSize => {
write!(fmt, "quantization parameter size does not match input")
}
Self::OutputSizeMismatch => write!(fmt, "output buffer has wrong length"),
Self::PackedDataKernelMismatch => {
write!(fmt, "matrix was packed with a different kernel")
}
Self::PackedDataBlockingMismatch => {
write!(fmt, "matrix was packed with a different blocking size")
}
Self::BlockQuantizedInputNotSupported => {
write!(fmt, "block-quantized inputs not supported for data type")
}
Self::QuantBitsNotSupported => {
write!(
fmt,
"quantized input has an unsupported number of bits per element"
)
}
}
}
}
impl Error for GemmError {}
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum BlockQuantizedError {
UnsupportedBlockSize,
UnsupportedElementSize,
}
impl Display for BlockQuantizedError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
Self::UnsupportedBlockSize => write!(f, "block size is unsupported"),
Self::UnsupportedElementSize => write!(f, "unsupported bits-per-element"),
}
}
}
impl Error for BlockQuantizedError {}