-
Notifications
You must be signed in to change notification settings - Fork 482
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add cumulative sum tensor operation #1722
Changes from 1 commit
b7188aa
c51d7be
729778e
ed7681e
9175f92
3a477a2
46cc2c8
91c27b4
fdc5c95
8b9b39e
dab2905
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
// Language | ||
use alloc::vec::Vec; | ||
use core::ops::Range; | ||
use ndarray::IntoDimension; | ||
use ndarray::{Axis, IntoDimension}; | ||
|
||
// Current crate | ||
use super::{matmul::matmul, NdArrayMathOps, NdArrayOps}; | ||
|
@@ -338,6 +338,17 @@ impl<E: FloatNdArrayElement> FloatTensorOps<Self> for NdArray<E> { | |
NdArrayMathOps::sum_dim(tensor, dim) | ||
} | ||
|
||
fn float_cumsum_dim<const D: usize>( | ||
tensor: NdArrayTensor<E, D>, | ||
dim: usize, | ||
) -> NdArrayTensor<E, D> { | ||
let mut array = tensor.array.clone().into_owned(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe the underlying array struct of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Well |
||
|
||
array.accumulate_axis_inplace(Axis(dim), |&prev, curr| *curr += prev); | ||
|
||
NdArrayTensor::new(array.to_shared()) | ||
} | ||
|
||
fn float_argmax<const D: usize>( | ||
tensor: NdArrayTensor<E, D>, | ||
dim: usize, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See comment for
float_cumsum