-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1e707a5
commit 360cdd4
Showing
3 changed files
with
22 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,16 @@ | ||
# Copyright (c) 2023 Graphcore Ltd. All rights reserved. | ||
import jax.numpy as jnp | ||
from jax.experimental import enable_x64 | ||
from numpy.testing import assert_allclose | ||
|
||
from pyscf_ipu.experimental.integrals import factorial_fori, factorial_gamma | ||
from pyscf_ipu.experimental.numerics import compare_fp32_to_fp64 | ||
|
||
|
||
def test_factorial(): | ||
x = jnp.arange(8, dtype=jnp.float32) | ||
y_fori = compare_fp32_to_fp64(factorial_fori)(x, 8) | ||
y_gamma = compare_fp32_to_fp64(factorial_gamma)(x) | ||
assert_allclose(y_fori, y_gamma, atol=1e-2) | ||
with enable_x64(): | ||
n = 16 | ||
x = jnp.arange(n, dtype=jnp.float32) | ||
y_fori = compare_fp32_to_fp64(factorial_fori)(x, n) | ||
y_gamma = compare_fp32_to_fp64(factorial_gamma)(x) | ||
assert_allclose(y_fori, y_gamma, 1e-2) |