Skip to content
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 four backend method tests,including 'sin','cos','copy' and 'power' #105

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions tests/test_backends.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,16 @@ def test_backend_methods(backend):
np.array([2, 1, 0]),
atol=1e-5,
)
np.testing.assert_allclose(
tc.backend.copy(arr),
arr,
atol=1e-5,
)
np.testing.assert_allclose(
tc.backend.power(arr,6),
np.power(arr,6),
atol=1e-5
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could these two methods tests also move to test_backend_method_2? namely, whether currently pytorch backend supports these two methods

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes,change will be committed soon



@pytest.mark.parametrize("backend", [lf("npb"), lf("tfb"), lf("jaxb"), lf("torchb")])
Expand Down Expand Up @@ -241,6 +251,16 @@ def test_backend_methods_2(backend):
np.sinh(0.5 * tc.backend.ones([2])),
atol=1e-5,
)
np.testing.assert_allclose(
tc.backend.sin(0.5*tc.backend.ones([2],dtype="float32")),
np.sin(0.5*tc.backend.ones([2])),
atol=1e-5,
)
np.testing.assert_allclose(
tc.backend.cos(0.5*tc.backend.ones([2],dtype="float32")),
np.cos(0.5*tc.backend.ones([2])),
atol=1e-5,
)
np.testing.assert_allclose(
tc.backend.eigvalsh(tc.backend.ones([2, 2])), np.array([0, 2]), atol=1e-5
)
Expand Down