@@ -553,7 +553,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_multivariate_normal(numpy.ndarray mean, num
553
553
return result
554
554
555
555
556
- cpdef dparray dpnp_rng_negative_binomial(double a, double p, size):
556
+ cpdef utils.dpnp_descriptor dpnp_rng_negative_binomial(double a, double p, size):
557
557
"""
558
558
Returns an array populated with samples from negative binomial distribution.
559
559
@@ -564,28 +564,27 @@ cpdef dparray dpnp_rng_negative_binomial(double a, double p, size):
564
564
"""
565
565
566
566
dtype = numpy.int32
567
- cdef dparray result
567
+ cdef utils.dpnp_descriptor result
568
568
cdef DPNPFuncType param1_type
569
569
cdef DPNPFuncData kernel_data
570
570
cdef fptr_dpnp_rng_negative_binomial_c_1out_t func
571
-
571
+ cdef dparray_shape_type result_shape
572
+
572
573
if p == 0.0 :
573
574
filled_val = numpy.iinfo(dtype).min
574
- result = dparray(size, dtype = dtype)
575
- result.fill(filled_val)
575
+ return dpnp_full(size, filled_val, dtype)
576
576
elif p == 1.0 :
577
- result = dparray(size, dtype = dtype)
578
- result.fill(0 )
577
+ return dpnp_full(size, 0 , dtype)
579
578
else :
580
579
# convert string type names (dparray.dtype) to C enum DPNPFuncType
581
580
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
582
581
583
582
# get the FPTR data structure
584
583
kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_NEGATIVE_BINOMIAL, param1_type, param1_type)
585
584
586
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
587
585
# ceate result array with type given by FPTR data
588
- result = dparray(size, dtype = result_type)
586
+ result_shape = utils._object_to_tuple(size)
587
+ result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
589
588
590
589
func = < fptr_dpnp_rng_negative_binomial_c_1out_t > kernel_data.ptr
591
590
# call FPTR function
@@ -619,7 +618,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_noncentral_chisquare(double df, double nonc
619
618
return result
620
619
621
620
622
- cpdef dparray dpnp_rng_normal(double loc, double scale, size):
621
+ cpdef utils.dpnp_descriptor dpnp_rng_normal(double loc, double scale, size):
623
622
"""
624
623
Returns an array populated with samples from normal distribution.
625
624
`dpnp_rng_normal` generates a matrix filled with random floats sampled from a
@@ -628,24 +627,24 @@ cpdef dparray dpnp_rng_normal(double loc, double scale, size):
628
627
"""
629
628
630
629
dtype = numpy.float64
631
- cdef dparray result
630
+ cdef dparray_shape_type result_shape
631
+ cdef utils.dpnp_descriptor result
632
632
cdef DPNPFuncType param1_type
633
633
cdef DPNPFuncData kernel_data
634
634
cdef fptr_dpnp_rng_normal_c_1out_t func
635
635
636
636
if scale == 0.0 :
637
- result = dparray(size, dtype = dtype)
638
- result.fill(loc)
637
+ return dpnp_full(size, loc, dtype)
639
638
else :
640
639
# convert string type names (dparray.dtype) to C enum DPNPFuncType
641
640
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
642
641
643
642
# get the FPTR data structure
644
643
kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_NORMAL, param1_type, param1_type)
645
644
646
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
647
645
# ceate result array with type given by FPTR data
648
- result = dparray(size, dtype = result_type)
646
+ result_shape = utils._object_to_tuple(size)
647
+ result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
649
648
650
649
func = < fptr_dpnp_rng_normal_c_1out_t > kernel_data.ptr
651
650
# call FPTR function
@@ -680,7 +679,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_pareto(double alpha, size):
680
679
return result
681
680
682
681
683
- cpdef dparray dpnp_rng_poisson(double lam, size):
682
+ cpdef utils.dpnp_descriptor dpnp_rng_poisson(double lam, size):
684
683
"""
685
684
Returns an array populated with samples from Poisson distribution.
686
685
`dpnp_rng_poisson` generates a matrix filled with random floats sampled from a
@@ -690,24 +689,24 @@ cpdef dparray dpnp_rng_poisson(double lam, size):
690
689
"""
691
690
692
691
dtype = numpy.int32
693
- cdef dparray result
692
+ cdef dparray_shape_type result_shape
693
+ cdef utils.dpnp_descriptor result
694
694
cdef DPNPFuncType param1_type
695
695
cdef DPNPFuncData kernel_data
696
696
cdef fptr_dpnp_rng_poisson_c_1out_t func
697
697
698
698
if lam == 0 :
699
- result = dparray(size, dtype = dtype)
700
- result.fill(0 )
699
+ return dpnp_full(size, 0 , dtype)
701
700
else :
702
701
# convert string type names (dparray.dtype) to C enum DPNPFuncType
703
702
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
704
703
705
704
# get the FPTR data structure
706
705
kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_POISSON, param1_type, param1_type)
707
706
708
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
709
707
# ceate result array with type given by FPTR data
710
- result = dparray(size, dtype = result_type)
708
+ result_shape = utils._object_to_tuple(size)
709
+ result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
711
710
712
711
func = < fptr_dpnp_rng_poisson_c_1out_t > kernel_data.ptr
713
712
# call FPTR function
@@ -794,7 +793,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_random(dims):
794
793
return result
795
794
796
795
797
- cpdef dparray dpnp_rng_rayleigh(double scale, size):
796
+ cpdef utils.dpnp_descriptor dpnp_rng_rayleigh(double scale, size):
798
797
"""
799
798
Returns an array populated with samples from Rayleigh distribution.
800
799
`dpnp_rayleigh` generates a matrix filled with random floats sampled from a
@@ -803,24 +802,24 @@ cpdef dparray dpnp_rng_rayleigh(double scale, size):
803
802
"""
804
803
805
804
dtype = numpy.float64
806
- cdef dparray result
805
+ cdef dparray_shape_type result_shape
806
+ cdef utils.dpnp_descriptor result
807
807
cdef DPNPFuncType param1_type
808
808
cdef DPNPFuncData kernel_data
809
809
cdef fptr_dpnp_rng_rayleigh_c_1out_t func
810
810
811
811
if scale == 0.0 :
812
- result = dparray(size, dtype = dtype)
813
- result.fill(0.0 )
812
+ return dpnp_full(size, 0.0 , dtype)
814
813
else :
815
814
# convert string type names (dparray.dtype) to C enum DPNPFuncType
816
815
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
817
816
818
817
# get the FPTR data structure
819
818
kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_RAYLEIGH, param1_type, param1_type)
820
819
821
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
822
820
# ceate result array with type given by FPTR data
823
- result = dparray(size, dtype = result_type)
821
+ result_shape = utils._object_to_tuple(size)
822
+ result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
824
823
825
824
func = < fptr_dpnp_rng_rayleigh_c_1out_t > kernel_data.ptr
826
825
# call FPTR function
@@ -920,7 +919,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_exponential(size):
920
919
return result
921
920
922
921
923
- cpdef dparray dpnp_rng_standard_gamma(double shape, size):
922
+ cpdef utils.dpnp_descriptor dpnp_rng_standard_gamma(double shape, size):
924
923
"""
925
924
Returns an array populated with samples from standard gamma distribution.
926
925
`dpnp_standard_gamma` generates a matrix filled with random floats sampled from a
@@ -929,24 +928,24 @@ cpdef dparray dpnp_rng_standard_gamma(double shape, size):
929
928
"""
930
929
931
930
dtype = numpy.float64
932
- cdef dparray result
931
+ cdef dparray_shape_type result_shape
932
+ cdef utils.dpnp_descriptor result
933
933
cdef DPNPFuncType param1_type
934
934
cdef DPNPFuncData kernel_data
935
935
cdef fptr_dpnp_rng_standard_gamma_c_1out_t func
936
936
937
937
if shape == 0.0 :
938
- result = dparray(size, dtype = dtype)
939
- result.fill(0.0 )
938
+ return dpnp_full(size, 0.0 , dtype)
940
939
else :
941
940
# convert string type names (dparray.dtype) to C enum DPNPFuncType
942
941
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
943
942
944
943
# get the FPTR data structure
945
944
kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_STANDARD_GAMMA, param1_type, param1_type)
946
945
947
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
948
946
# ceate result array with type given by FPTR data
949
- result = dparray(size, dtype = result_type)
947
+ result_shape = utils._object_to_tuple(size)
948
+ result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
950
949
951
950
func = < fptr_dpnp_rng_standard_gamma_c_1out_t > kernel_data.ptr
952
951
# call FPTR function
@@ -1030,7 +1029,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_triangular(double left, double mode, double
1030
1029
return result
1031
1030
1032
1031
1033
- cpdef dparray dpnp_rng_uniform(long low, long high, size, dtype):
1032
+ cpdef utils.dpnp_descriptor dpnp_rng_uniform(long low, long high, size, dtype):
1034
1033
"""
1035
1034
Returns an array populated with samples from standard uniform distribution.
1036
1035
Generates a matrix filled with random numbers sampled from a
@@ -1039,24 +1038,24 @@ cpdef dparray dpnp_rng_uniform(long low, long high, size, dtype):
1039
1038
1040
1039
"""
1041
1040
1042
- cdef dparray result
1041
+ cdef dparray_shape_type result_shape
1042
+ cdef utils.dpnp_descriptor result
1043
1043
cdef DPNPFuncType param1_type
1044
1044
cdef DPNPFuncData kernel_data
1045
1045
cdef fptr_dpnp_rng_uniform_c_1out_t func
1046
1046
1047
1047
if low == high:
1048
- result = dparray(size, dtype = dtype)
1049
- result.fill(low)
1048
+ return dpnp_full(size, low, dtype)
1050
1049
else :
1051
1050
# convert string type names (dparray.dtype) to C enum DPNPFuncType
1052
1051
param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
1053
1052
1054
1053
# get the FPTR data structure
1055
1054
kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_UNIFORM, param1_type, param1_type)
1056
1055
1057
- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
1058
1056
# ceate result array with type given by FPTR data
1059
- result = dparray(size, dtype = result_type)
1057
+ result_shape = utils._object_to_tuple(size)
1058
+ result = utils.create_output_descriptor(result_shape, kernel_data.return_type, None )
1060
1059
1061
1060
func = < fptr_dpnp_rng_uniform_c_1out_t > kernel_data.ptr
1062
1061
# call FPTR function
0 commit comments