Skip to main content

numr/ops/cpu/
cumulative.rs

1//! CPU implementation of cumulative operations.
2
3use crate::error::Result;
4use crate::ops::CumulativeOps;
5use crate::runtime::cpu::{
6    CpuClient, CpuRuntime,
7    helpers::{cumprod_impl, cumsum_impl, logsumexp_impl},
8};
9use crate::tensor::Tensor;
10
11/// CumulativeOps implementation for CPU runtime.
12impl CumulativeOps<CpuRuntime> for CpuClient {
13    fn cumsum(&self, a: &Tensor<CpuRuntime>, dim: isize) -> Result<Tensor<CpuRuntime>> {
14        cumsum_impl(self, a, dim)
15    }
16
17    fn cumprod(&self, a: &Tensor<CpuRuntime>, dim: isize) -> Result<Tensor<CpuRuntime>> {
18        cumprod_impl(self, a, dim)
19    }
20
21    fn logsumexp(
22        &self,
23        a: &Tensor<CpuRuntime>,
24        dims: &[usize],
25        keepdim: bool,
26    ) -> Result<Tensor<CpuRuntime>> {
27        logsumexp_impl(self, a, dims, keepdim)
28    }
29}