#[derive(Debug)]
pub enum LoraStdError {
ShapeMismatch,
}
impl From<native_neural_network::lora::LoraError> for LoraStdError {
fn from(e: native_neural_network::lora::LoraError) -> Self {
match e {
native_neural_network::lora::LoraError::ShapeMismatch => LoraStdError::ShapeMismatch,
}
}
}
pub fn apply_lora_delta(
base_weight: &mut [f32],
rows: usize,
cols: usize,
a: &[f32],
b: &[f32],
rank: usize,
alpha: f32,
) -> Result<(), LoraStdError> {
native_neural_network::lora::apply_lora_delta(base_weight, rows, cols, a, b, rank, alpha)
.map_err(|e| e.into())
}
impl core::fmt::Display for LoraStdError {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "LoraStdError::{:?}", self)
}
}
impl std::error::Error for LoraStdError {}