-
Notifications
You must be signed in to change notification settings - Fork 443
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add is_nan and contains_nan tensor ops (#2088)
* Add is_nan and contains_nan tensor ops * Enable nan test for burn-candle * Disabling tests due to #2089
- Loading branch information
Showing
6 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -34,6 +34,7 @@ mod matmul; | |
mod maxmin; | ||
mod movedim; | ||
mod mul; | ||
mod nan; | ||
mod narrow; | ||
mod neg; | ||
mod one_hot; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#[burn_tensor_testgen::testgen(nan)] | ||
mod tests { | ||
use super::*; | ||
use burn_tensor::{Int, Tensor, TensorData}; | ||
|
||
#[test] | ||
#[ignore = "https://github.com/tracel-ai/burn/issues/2089"] | ||
fn is_nan() { | ||
let no_nan = TestTensor::<2>::from([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]); | ||
let no_nan_expected = | ||
TestTensorBool::<2>::from([[false, false, false], [false, false, false]]); | ||
|
||
let with_nan = TestTensor::<2>::from([[0.0, f32::NAN, 2.0], [f32::NAN, 4.0, 5.0]]); | ||
let with_nan_expected = | ||
TestTensorBool::<2>::from([[false, true, false], [true, false, false]]); | ||
|
||
assert_eq!(no_nan_expected.into_data(), no_nan.is_nan().into_data()); | ||
|
||
assert_eq!(with_nan_expected.into_data(), with_nan.is_nan().into_data()); | ||
} | ||
|
||
#[test] | ||
#[ignore = "https://github.com/tracel-ai/burn/issues/2089"] | ||
fn contains_nan() { | ||
let no_nan = TestTensor::<2>::from([[0.0, 1.0, 2.0], [3.0, 4.0, 5.0]]); | ||
assert!(!no_nan.contains_nan().into_scalar()); | ||
|
||
let with_nan = TestTensor::<2>::from([[0.0, f32::NAN, 2.0], [3.0, 4.0, 5.0]]); | ||
assert!(with_nan.contains_nan().into_scalar()); | ||
} | ||
} |