5555FLAGS = config .FLAGS
5656
5757
58+ numpy_version = tuple (map (int , np .__version__ .split ('.' )[:3 ]))
59+
60+
5861class CPPJitTest (jtu .BufferDonationTestCase ):
5962 """Shared tests between the Python and the C++ jax,jit implementations.
6063
@@ -1484,47 +1487,61 @@ def test_grad_of_int_errors(self):
14841487 r"sub-dtype of np.floating or np.complexfloating\), but got int.*." ),
14851488 lambda : dfn (3 ))
14861489
1490+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1491+ "https://github.com/numpy/numpy/issues/19305" )
14871492 def test_jvp_of_int_identity (self ):
14881493 primals = (1 ,)
14891494 tangents = (np .zeros (shape = (), dtype = float0 ),)
14901495
14911496 _ , out = api .jvp (lambda x : x , primals , tangents )
14921497 self .assertEqual (out , np .zeros (shape = (), dtype = float0 ))
14931498
1499+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1500+ "https://github.com/numpy/numpy/issues/19305" )
14941501 def test_jvp_of_int_add (self ):
14951502 primals = (2 ,)
14961503 tangents = (np .zeros (shape = (), dtype = float0 ),)
14971504
14981505 _ , out_tangent = api .jvp (lambda x : x + 1 , primals , tangents )
14991506 self .assertEqual (out_tangent , np .zeros (shape = (), dtype = float0 ))
15001507
1508+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1509+ "https://github.com/numpy/numpy/issues/19305" )
15011510 def test_jit_jvp_of_int (self ):
15021511 primals = (2 ,)
15031512 tangents = (np .zeros (shape = (), dtype = float0 ),)
15041513
15051514 _ , out_tangent = api .jvp (jax .jit (lambda x : x + 1 ), primals , tangents )
15061515 self .assertEqual (out_tangent , np .zeros (shape = (), dtype = float0 ))
15071516
1517+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1518+ "https://github.com/numpy/numpy/issues/19305" )
15081519 def test_vjp_of_int_index (self ):
15091520 primal , fn_vjp = api .vjp (lambda x , i : x [i ], np .ones (2 )* 2 , 1 )
15101521 tangent_x , tangent_i = fn_vjp (1. )
15111522 self .assertEqual (primal , 2. )
15121523 self .assertAllClose (tangent_x , jnp .array ([0. , 1. ]))
15131524 self .assertEqual (tangent_i , np .zeros (shape = (), dtype = float0 ))
15141525
1526+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1527+ "https://github.com/numpy/numpy/issues/19305" )
15151528 def test_vjp_of_int_shapes (self ):
15161529 out , fn_vjp = api .vjp (lambda x : lax .reshape (x , (2 , 2 )), np .ones ((4 , 1 ),
15171530 dtype = int ))
15181531 tangent , = fn_vjp (out )
15191532 self .assertArraysEqual (tangent , np .zeros (shape = (4 , 1 ), dtype = float0 ))
15201533
1534+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1535+ "https://github.com/numpy/numpy/issues/19305" )
15211536 def test_jit_vjp_of_int (self ):
15221537 primal , fn_vjp = api .vjp (lambda x , y : x + y , 2 , 1 )
15231538 tangent_x , tangent_i = jax .jit (fn_vjp )(1 )
15241539 self .assertEqual (primal , 3 )
15251540 self .assertEqual (tangent_x , np .zeros (shape = (), dtype = float0 ))
15261541 self .assertEqual (tangent_i , np .zeros (shape = (), dtype = float0 ))
15271542
1543+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1544+ "https://github.com/numpy/numpy/issues/19305" )
15281545 def test_vjp_of_int_fulllike (self ):
15291546 # Regression test for tangent and cotangent mismatch in convert_element_type
15301547 # transpose rule wrt a ConstVar
@@ -1535,30 +1552,40 @@ def test_vjp_of_int_fulllike(self):
15351552 self .assertAllClose (tangent_x , jnp .zeros ((2 , 2 )))
15361553 self .assertEqual (tangent_y , np .zeros (shape = (), dtype = float0 ))
15371554
1555+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1556+ "https://github.com/numpy/numpy/issues/19305" )
15381557 def test_grad_of_int (self ):
15391558 # Need real-valued output, but testing integer input.
15401559 out = api .grad (lambda x : x + 0. , allow_int = True )(1 )
15411560 self .assertEqual (out , np .zeros (shape = (), dtype = float0 ))
15421561
1562+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1563+ "https://github.com/numpy/numpy/issues/19305" )
15431564 def test_grad_of_bool (self ):
15441565 def cond (pred ):
15451566 return lax .cond (pred , lambda _ : 1. , lambda _ : 2. , 1. )
15461567 value , grd = api .value_and_grad (cond , allow_int = True )(True )
15471568 self .assertEqual (value , 1. )
15481569 self .assertEqual (grd , np .zeros (shape = (), dtype = float0 ))
15491570
1571+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1572+ "https://github.com/numpy/numpy/issues/19305" )
15501573 def test_grad_of_int_index (self ):
15511574 grad_x , grad_i = api .grad (lambda x , i : x [i ], argnums = (0 , 1 ),
15521575 allow_int = True )(np .ones (2 ), 1 )
15531576 self .assertAllClose (grad_x , jnp .array ([0. , 1. ]))
15541577 self .assertEqual (grad_i , np .zeros (shape = (), dtype = float0 ))
15551578
1579+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1580+ "https://github.com/numpy/numpy/issues/19305" )
15561581 def test_jit_grad_of_int (self ):
15571582 grad_f = api .grad (lambda x , i : x [i ], argnums = (0 , 1 ), allow_int = True )
15581583 grad_x , grad_i = jax .jit (grad_f )(np .ones (2 ), 1 )
15591584 self .assertAllClose (grad_x , jnp .array ([0. , 1. ]))
15601585 self .assertEqual (grad_i , np .zeros (shape = (), dtype = float0 ))
15611586
1587+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
1588+ "https://github.com/numpy/numpy/issues/19305" )
15621589 def test_float0_reshape (self ):
15631590 # dtype-agnostic operations are supported
15641591 float0_array = jax .grad (lambda x : jnp .sum (x + 0. ),
@@ -3894,6 +3921,8 @@ def f_jvp(primal, tangent):
38943921
38953922 api .vmap (sample )(jax .random .split (jax .random .PRNGKey (1 ), 3 )) # don't crash
38963923
3924+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
3925+ "https://github.com/numpy/numpy/issues/19305" )
38973926 def test_float0 (self ):
38983927 @api .custom_jvp
38993928 def f (x , y ):
@@ -3909,6 +3938,8 @@ def f_jvp(primals, _):
39093938 self .assertArraysEqual (api .jvp (f , primals , tangents ),
39103939 (primals , expected_tangents ))
39113940
3941+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
3942+ "https://github.com/numpy/numpy/issues/19305" )
39123943 def test_float0_initial_style (self ):
39133944 @api .custom_jvp
39143945 def f (x , y ):
@@ -4837,6 +4868,8 @@ def bwd(y, g):
48374868 ans = jax .grad (f )(4. )
48384869 self .assertAllClose (ans , - 2. * jnp .sin (4. ))
48394870
4871+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
4872+ "https://github.com/numpy/numpy/issues/19305" )
48404873 def test_float0 (self ):
48414874 @api .custom_vjp
48424875 def f (x , _ ):
@@ -4853,6 +4886,8 @@ def f_rev(*_):
48534886 self .assertEqual (api .grad (f , allow_int = True , argnums = (0 , 1 ))(x , y ),
48544887 (2. , np .zeros (shape = (), dtype = float0 )))
48554888
4889+ @unittest .skipIf (numpy_version == (1 , 21 , 0 ),
4890+ "https://github.com/numpy/numpy/issues/19305" )
48564891 def test_float0_initial_style (self ):
48574892 @api .custom_vjp
48584893 def f (x ):
0 commit comments