mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-01 21:04:41 +08:00
Adds isinf (#445)
* adds isinf Signed-off-by: matthewfernst <matthew.f.ernst@gmail.com> * use stream + nits * typo --------- Signed-off-by: matthewfernst <matthew.f.ernst@gmail.com> Co-authored-by: Awni Hannun <awni@apple.com>
This commit is contained in:
@@ -505,6 +505,32 @@ TEST_CASE("test is nan") {
|
||||
CHECK(isnan(d).item<bool>());
|
||||
}
|
||||
|
||||
TEST_CASE("test is inf") {
|
||||
array x(1.0f);
|
||||
CHECK_FALSE(isinf(x).item<bool>());
|
||||
|
||||
array y(std::numeric_limits<double>::infinity());
|
||||
CHECK(isinf(y).item<bool>());
|
||||
|
||||
array z = identity(7);
|
||||
CHECK_FALSE(any(isinf(z)).item<bool>());
|
||||
|
||||
array w = array({1.0f, std::numeric_limits<double>::infinity(), 2.0f});
|
||||
CHECK(array_equal({false, true, false}, isinf(w)).item<bool>());
|
||||
|
||||
array a(1.0f, bfloat16);
|
||||
CHECK_FALSE(isinf(a).item<bool>());
|
||||
|
||||
array b(1.0f, float16);
|
||||
CHECK_FALSE(isinf(b).item<bool>());
|
||||
|
||||
array c(std::numeric_limits<double>::infinity(), bfloat16);
|
||||
CHECK(isinf(c).item<bool>());
|
||||
|
||||
array d(std::numeric_limits<double>::infinity(), float16);
|
||||
CHECK(isinf(d).item<bool>());
|
||||
}
|
||||
|
||||
TEST_CASE("test all close") {
|
||||
array x(1.0f);
|
||||
array y(1.0f);
|
||||
|
Reference in New Issue
Block a user