13
13
get_all_dtypes ,
14
14
get_complex_dtypes ,
15
15
get_float_dtypes ,
16
- is_cpu_device ,
17
16
)
18
17
19
- # aspects of default device:
20
- _def_device = dpctl .SyclQueue ().sycl_device
21
- _def_dev_has_fp64 = _def_device .has_aspect_fp64
22
- is_gpu_with_fp64 = not is_cpu_device () and _def_dev_has_fp64
23
-
24
18
25
19
# TODO: `assert_dtype_allclose` calls in this file have `check_only_type_kind=True`
26
20
# since stock NumPy is currently used in public CI for code coverege which
@@ -396,6 +390,10 @@ def test_hfft_1D(self, dtype, n, norm):
396
390
def test_hfft_1D_complex (self , dtype , n , norm ):
397
391
x = dpnp .linspace (- 1 , 1 , 11 )
398
392
a = dpnp .sin (x ) + 1j * dpnp .cos (x )
393
+ # input should be Hermitian
394
+ a [0 ].imag = 0
395
+ if n in [None , 20 ]: # Nyquist mode
396
+ a [- 1 ].imag = 0
399
397
a = dpnp .asarray (a , dtype = dtype )
400
398
a_np = dpnp .asnumpy (a )
401
399
@@ -446,13 +444,16 @@ def test_fft_1D(self, dtype, n, norm):
446
444
# but dpnp return float32 if input is float32
447
445
assert_dtype_allclose (result , expected , check_only_type_kind = True )
448
446
449
- @pytest .mark .skipif (is_gpu_with_fp64 , reason = "MKLD17702" )
450
447
@pytest .mark .parametrize ("dtype" , get_complex_dtypes ())
451
448
@pytest .mark .parametrize ("n" , [None , 5 , 20 ])
452
449
@pytest .mark .parametrize ("norm" , ["forward" , "backward" , "ortho" ])
453
450
def test_fft_1D_complex (self , dtype , n , norm ):
454
451
x = dpnp .linspace (- 1 , 1 , 11 )
455
452
a = dpnp .sin (x ) + 1j * dpnp .cos (x )
453
+ # input should be Hermitian
454
+ a [0 ].imag = 0
455
+ if n in [None , 20 ]: # Nyquist mode
456
+ a [- 1 ].imag = 0
456
457
a = dpnp .asarray (a , dtype = dtype )
457
458
a_np = dpnp .asnumpy (a )
458
459
@@ -473,29 +474,39 @@ def test_fft_1D_on_2D_array(self, dtype, n, axis, norm, order):
473
474
expected = numpy .fft .irfft (a_np , n = n , axis = axis , norm = norm )
474
475
assert_dtype_allclose (result , expected , check_only_type_kind = True )
475
476
476
- @pytest .mark .skipif (is_gpu_with_fp64 , reason = "MKLD17702" )
477
477
@pytest .mark .parametrize ("dtype" , get_complex_dtypes ())
478
478
@pytest .mark .parametrize ("n" , [None , 5 , 8 ])
479
479
@pytest .mark .parametrize ("axis" , [0 , 1 , 2 ])
480
480
@pytest .mark .parametrize ("norm" , ["forward" , "backward" , "ortho" ])
481
481
@pytest .mark .parametrize ("order" , ["C" , "F" ])
482
482
def test_fft_1D_on_3D_array (self , dtype , n , axis , norm , order ):
483
- x1 = numpy .random .uniform (- 10 , 10 , 24 )
484
- x2 = numpy .random .uniform (- 10 , 10 , 24 )
483
+ x1 = numpy .random .uniform (- 10 , 10 , 120 )
484
+ x2 = numpy .random .uniform (- 10 , 10 , 120 )
485
485
a_np = numpy .array (x1 + 1j * x2 , dtype = dtype ).reshape (
486
- 2 , 3 , 4 , order = order
486
+ 4 , 5 , 6 , order = order
487
487
)
488
+ # each 1-D array of input should be Hermitian
489
+ a_np [0 ].imag = 0
490
+ a_np [:, 0 , :].imag = 0
491
+ a_np [..., 0 ].imag = 0
492
+ # If output size is even, this is Nyquist mode
493
+ a_np [- 1 ].imag = 0
494
+ a_np [:, - 1 , :].imag = 0
495
+ a_np [..., - 1 ].imag = 0
488
496
a = dpnp .asarray (a_np )
489
497
490
498
result = dpnp .fft .irfft (a , n = n , axis = axis , norm = norm )
491
499
expected = numpy .fft .irfft (a_np , n = n , axis = axis , norm = norm )
492
500
assert_dtype_allclose (result , expected , check_only_type_kind = True )
493
501
494
- @pytest .mark .skipif (is_gpu_with_fp64 , reason = "MKLD17702" )
495
502
@pytest .mark .parametrize ("n" , [None , 5 , 20 ])
496
503
def test_fft_usm_ndarray (self , n ):
497
504
x = dpt .linspace (- 1 , 1 , 11 )
498
505
a = dpt .sin (x ) + 1j * dpt .cos (x )
506
+ # input should be Hermitian
507
+ a [0 ] = dpt .sin (x [0 ])
508
+ if n in [None , 20 ]: # Nyquist mode
509
+ a [- 1 ] = dpt .sin (x [- 1 ])
499
510
a_usm = dpt .asarray (a , dtype = dpt .complex64 )
500
511
a_np = dpt .asnumpy (a_usm )
501
512
out_shape = n if n is not None else 2 * (a_usm .shape [0 ] - 1 )
@@ -506,13 +517,16 @@ def test_fft_usm_ndarray(self, n):
506
517
expected = numpy .fft .irfft (a_np , n = n )
507
518
assert_dtype_allclose (result , expected , check_only_type_kind = True )
508
519
509
- @pytest .mark .skipif (is_gpu_with_fp64 , reason = "MKLD17702" )
510
520
@pytest .mark .parametrize ("dtype" , get_complex_dtypes ())
511
521
@pytest .mark .parametrize ("n" , [None , 5 , 20 ])
512
522
@pytest .mark .parametrize ("norm" , ["forward" , "backward" , "ortho" ])
513
523
def test_fft_1D_out (self , dtype , n , norm ):
514
524
x = dpnp .linspace (- 1 , 1 , 11 )
515
525
a = dpnp .sin (x ) + 1j * dpnp .cos (x )
526
+ # input should be Hermitian
527
+ a [0 ].imag = 0
528
+ if n in [None , 20 ]: # Nyquist mode
529
+ a [- 1 ].imag = 0
516
530
a = dpnp .asarray (a , dtype = dtype )
517
531
a_np = dpnp .asnumpy (a )
518
532
0 commit comments