use coeus_core::{ComputeBackend, Layout, Scalar};
pub trait CrossEntropyOps<T: Scalar>: ComputeBackend {
type Targets: Send + Sync + 'static;
fn prepare_cross_entropy_targets(
&self,
targets: &[usize],
) -> Result<Self::Targets, Self::Error>;
#[expect(
clippy::too_many_arguments,
reason = "the method carries the complete provider forward contract"
)]
fn cross_entropy_forward(
&self,
logits: &Self::DeviceBuffer<T>,
logits_layout: &Layout,
targets: &Self::Targets,
loss: &mut Self::DeviceBuffer<T>,
loss_layout: &Layout,
probabilities: &mut Self::DeviceBuffer<T>,
probabilities_layout: &Layout,
) -> Result<(), Self::Error>;
#[expect(
clippy::too_many_arguments,
reason = "the method carries the complete provider backward contract"
)]
fn cross_entropy_backward_accumulate(
&self,
output_gradient: &Self::DeviceBuffer<T>,
output_gradient_layout: &Layout,
probabilities: &Self::DeviceBuffer<T>,
probabilities_layout: &Layout,
targets: &Self::Targets,
logit_gradient: &mut Self::DeviceBuffer<T>,
logit_gradient_layout: &Layout,
) -> Result<(), Self::Error>;
}