pub mod auxiliary;
mod element_op;
mod raw;
pub mod view;
pub use element_op::{
Adjoint, ComposableElementOp, Compose, Conj, ElementOp, ElementOpApply, Identity, Transpose,
};
pub use raw::{
ErasedRawStridedMut, ErasedRawStridedPtr, ErasedRawStridedRef, ErasedRawStridedUninitMut,
KernelDType, KernelStorageElement, RawStridedMut, RawStridedRef,
};
pub use view::{col_major_strides, row_major_strides, StridedArray, StridedView, StridedViewMut};
#[derive(Debug, thiserror::Error)]
pub enum StridedError {
#[error("rank mismatch: {0} vs {1}")]
RankMismatch(usize, usize),
#[error("shape mismatch: {0:?} vs {1:?}")]
ShapeMismatch(Vec<usize>, Vec<usize>),
#[error("invalid axis {axis} for rank {rank}")]
InvalidAxis { axis: usize, rank: usize },
#[error("stride and dims length mismatch")]
StrideLengthMismatch,
#[error("offset overflow while computing pointer")]
OffsetOverflow,
#[error("failed to convert scalar for scaling")]
ScalarConversion,
#[error("non-square matrix: rows={rows}, cols={cols}")]
NonSquare { rows: usize, cols: usize },
#[error("mutable output layout is not injective")]
NonInjectiveOutputLayout,
#[error("view layout does not match the compiled plan")]
PlanLayoutMismatch,
#[error("dtype mismatch: expected {expected}, got {actual}")]
DTypeMismatch {
expected: &'static str,
actual: &'static str,
},
#[error(
"byte length {byte_len} is not a multiple of element size {element_size} for dtype {dtype}"
)]
ByteLengthMismatch {
dtype: &'static str,
byte_len: usize,
element_size: usize,
},
#[error("data pointer for dtype {dtype} is not aligned to {alignment} bytes")]
DataAlignmentMismatch {
dtype: &'static str,
alignment: usize,
},
#[error("invalid bool byte value {value}")]
InvalidBoolByte { value: u8 },
#[error("invalid thread budget {max_threads}")]
InvalidThreadBudget { max_threads: usize },
#[error("unsupported dtype {dtype}")]
UnsupportedDType { dtype: &'static str },
#[error("unsupported op {op} for dtype {dtype}")]
UnsupportedOp {
op: &'static str,
dtype: &'static str,
},
#[error("destination overlaps input {input}")]
OverlappingInputOutput { input: usize },
#[error("integer {op} encountered a zero divisor")]
IntegerDivisionByZero { op: &'static str },
#[error("unsupported arity {arity}; maximum supported arity is {max}")]
UnsupportedArity { arity: usize, max: usize },
}
pub type Result<T> = std::result::Result<T, StridedError>;