std and expm1 (#973)

* std and expm1

* actually add expm1

* fix linux

* fix vjp

* relax tol for linux test

* Add it to the compilable primitives

---------

Co-authored-by: Angelos Katharopoulos <a_katharopoulos@apple.com>
This commit is contained in:
Awni Hannun
2024-04-08 14:26:01 -07:00
committed by GitHub
parent 76e63212ff
commit 42afe27e12
19 changed files with 332 additions and 6 deletions

View File

@@ -1092,6 +1092,20 @@ TEST_CASE("test arithmetic unary ops") {
CHECK(allclose(exp(x), expected).item<bool>());
}
// Test expm1
{
array x(-1.0f);
CHECK_EQ(expm1(x).item<float>(), doctest::Approx(std::expm1(-1.0f)));
x = array(1.0f);
CHECK_EQ(expm1(x).item<float>(), doctest::Approx(std::expm1(1.0f)));
// Integer input type
x = array(1);
CHECK_EQ(expm1(x).dtype(), float32);
CHECK_EQ(expm1(x).item<float>(), doctest::Approx(std::expm1(1.0f)));
}
// Test sine
{
array x(0.0);