use ndarray::array;
use crate::Tensor;
crate::codegen_tests! {
fn test_cumsum_1d(config) {
let x = Tensor::from_slice([1.0f32, 2.0, 3.0, 4.0]);
let mut result = x.cumsum(0).unwrap();
result.realize_with(&config).unwrap();
assert_eq!(result.as_vec::<f32>().unwrap(), [1.0, 3.0, 6.0, 10.0]);
}
fn test_cumsum_2d_axis0(config) {
let x = Tensor::from_ndarray(&array![[1.0f32, 2.0, 3.0], [4.0, 5.0, 6.0]]);
let mut result = x.cumsum(0).unwrap();
result.realize_with(&config).unwrap();
assert_eq!(result.as_vec::<f32>().unwrap(), [1.0, 2.0, 3.0, 5.0, 7.0, 9.0]);
}
fn test_cumsum_2d_axis1(config) {
let x = Tensor::from_ndarray(&array![[1.0f32, 2.0, 3.0], [4.0, 5.0, 6.0]]);
let mut result = x.cumsum(1).unwrap();
result.realize_with(&config).unwrap();
assert_eq!(result.as_vec::<f32>().unwrap(), [1.0, 3.0, 6.0, 4.0, 9.0, 15.0]);
}
fn test_cumsum_negative_axis(config) {
let x = Tensor::from_ndarray(&array![[1.0f32, 2.0, 3.0], [4.0, 5.0, 6.0]]);
let mut result = x.cumsum(-1).unwrap();
result.realize_with(&config).unwrap();
assert_eq!(result.as_vec::<f32>().unwrap(), [1.0, 3.0, 6.0, 4.0, 9.0, 15.0]);
}
}