use crate::ml::autograd;
use crate::runtime::KernelId;
use crate::{Matrix, Result};
use super::common::{mean_pointwise_loss, pointwise_loss_backward};
pub fn l1(prediction: &Matrix, target: &Matrix) -> Result<Matrix> {
let output = mean_pointwise_loss(
prediction,
target,
KernelId::MlL1F32,
crate::core::operation::ml::L1,
)?;
autograd::record_l1(prediction, target, &output)?;
Ok(output)
}
pub(in crate::ml) fn l1_backward(prediction: &Matrix, target: &Matrix) -> Result<Matrix> {
pointwise_loss_backward(
prediction,
target,
KernelId::MlL1BackwardF32,
crate::core::operation::ml::L1_BACKWARD,
)
}