Skip to content

Commit

Permalink
64 bit
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholaswogan committed Mar 28, 2024
1 parent 93ee906 commit 8e65c6f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/forwarddiff_const.f90
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module forwarddiff_const
use iso_fortran_env, only: wp => real32
use iso_fortran_env, only: wp => real64
end module
10 changes: 5 additions & 5 deletions test/test_jax.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,36 +47,36 @@ def test():
x = np.array(10.0,dtype=np.float32)
f = func_operators(x)
dfdx = jax.grad(func_operators)(x)
f1, dfdx1 = fil.read_record(np.float32)
f1, dfdx1 = fil.read_record(np.float64)
print(f/f1,dfdx/dfdx1)
assert np.isclose(f,f1) and np.isclose(dfdx,dfdx1)

x = np.array(10.0,dtype=np.float32)
f = func_intrinsics1(x)
dfdx = jax.grad(func_intrinsics1)(x)
f1, dfdx1 = fil.read_record(np.float32)
f1, dfdx1 = fil.read_record(np.float64)
print(f/f1,dfdx/dfdx1)
assert np.isclose(f,f1) and np.isclose(dfdx,dfdx1)

x = np.array(0.1,dtype=np.float32)
f = func_intrinsics2(x)
dfdx = jax.grad(func_intrinsics2)(x)
f1, dfdx1 = fil.read_record(np.float32)
f1, dfdx1 = fil.read_record(np.float64)
print(f/f1,dfdx/dfdx1)
assert np.isclose(f,f1) and np.isclose(dfdx,dfdx1)

x = np.array([1, 2],dtype=np.float32)
f = func_grad1(x)
dfdx = jax.grad(func_grad1)(x)
tmp = fil.read_record(np.float32)
tmp = fil.read_record(np.float64)
f1, dfdx1 = tmp[0],tmp[1:]
print(f/f1,dfdx/dfdx1)
assert np.isclose(f,f1) and np.all(np.isclose(dfdx,dfdx1))

x = np.array([3, 4],dtype=np.float32)
f = func_grad2(x)
dfdx = jax.grad(func_grad2)(x)
tmp = fil.read_record(np.float32)
tmp = fil.read_record(np.float64)
f1, dfdx1 = tmp[0],tmp[1:]
print(f/f1,dfdx/dfdx1)
assert np.isclose(f,f1) and np.all(np.isclose(dfdx,dfdx1))
Expand Down

0 comments on commit 8e65c6f

Please sign in to comment.