Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bokutotu committed Sep 23, 2024
1 parent 10e02ed commit 32f347f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions zenu-matrix/src/operation/max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ impl MaxIdx for Nvidia {
impl<T: Num, R: Repr<Item = T>, D: Device> Matrix<R, DimDyn, D> {
#[must_use]
pub fn max_idx(&self) -> DimDyn {
if self.shape().is_empty() {
return DimDyn::from(&[] as &[usize]);
}
let default_stride = self.to_default_stride();
let idx = <D as MaxIdx>::max_idx(
default_stride.as_ptr(),
Expand Down
8 changes: 4 additions & 4 deletions zenu-test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ macro_rules! assert_mat_eq_epsilon {
let epsilon = $epsilon;
let diff = mat.to_ref() - mat2.to_ref();
let abs = diff.abs();
let diff_asum = abs.asum();
if diff_asum > epsilon {
let diff_max = abs.max_item();
if diff_max > epsilon {
panic!(
"assertion failed: `(left == right)`\n\
left: \n{:?},\n\
right: \n{:?}\n\
diff: \n{:?}\n\
diff_asum: \n{:?}",
mat, mat2, diff, diff_asum
diff_max: \n{:?}",
mat, mat2, diff, diff_max
);
}
}};
Expand Down

0 comments on commit 32f347f

Please sign in to comment.