use coeus_core::{ComputeBackend, FloatElement, Layout, Scalar};
use super::super::defaults;
use super::super::ops::ReductionOp;
use super::super::CpuBackend;
pub trait ReductionOps<T: Scalar>: ComputeBackend {
fn reduce(
&self,
op: ReductionOp,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>;
fn reduce_mean(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>
where
T: FloatElement;
fn reduce_prod(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>
where
T: FloatElement;
fn argmax(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<i64>,
c_layout: &Layout,
) where
T: leto_ops::Scalar,
Self: CpuBackend,
{
defaults::reductions::argmax(self, a, a_layout, axis, c, c_layout)
}
fn argmin(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<i64>,
c_layout: &Layout,
) where
T: leto_ops::Scalar,
Self: CpuBackend,
{
defaults::reductions::argmin(self, a, a_layout, axis, c, c_layout)
}
#[expect(
clippy::too_many_arguments,
reason = "ratchet ATLAS-COEUS-LINT-RATCHET-097"
)]
fn topk(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
k: usize,
axis: usize,
largest: bool,
values: &mut Self::DeviceBuffer<T>,
values_layout: &Layout,
indices: &mut Self::DeviceBuffer<i64>,
indices_layout: &Layout,
) where
T: leto_ops::Scalar,
Self: CpuBackend,
{
defaults::reductions::topk(
self,
a,
a_layout,
k,
axis,
largest,
values,
values_layout,
indices,
indices_layout,
)
}
fn cumsum(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>
where
T: leto_ops::Scalar;
fn suffix_sum(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>
where
T: leto_ops::Scalar;
fn cumprod(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>
where
T: leto_ops::Scalar;
fn suffix_prod(
&self,
a: &Self::DeviceBuffer<T>,
a_layout: &Layout,
axis: usize,
c: &mut Self::DeviceBuffer<T>,
c_layout: &Layout,
) -> Result<(), Self::Error>
where
T: leto_ops::Scalar;
}