@@ -553,7 +553,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_multivariate_normal(numpy.ndarray mean, num
553553 return result
554554
555555
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):
557557 """
558558 Returns an array populated with samples from negative binomial distribution.
559559
@@ -564,28 +564,27 @@ cpdef dparray dpnp_rng_negative_binomial(double a, double p, size):
564564 """
565565
566566 dtype = numpy.int32
567- cdef dparray result
567+ cdef utils.dpnp_descriptor result
568568 cdef DPNPFuncType param1_type
569569 cdef DPNPFuncData kernel_data
570570 cdef fptr_dpnp_rng_negative_binomial_c_1out_t func
571-
571+ cdef dparray_shape_type result_shape
572+
572573 if p == 0.0 :
573574 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)
576576 elif p == 1.0 :
577- result = dparray(size, dtype = dtype)
578- result.fill(0 )
577+ return dpnp_full(size, 0 , dtype)
579578 else :
580579 # convert string type names (dparray.dtype) to C enum DPNPFuncType
581580 param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
582581
583582 # get the FPTR data structure
584583 kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_NEGATIVE_BINOMIAL, param1_type, param1_type)
585584
586- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
587585 # 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 )
589588
590589 func = < fptr_dpnp_rng_negative_binomial_c_1out_t > kernel_data.ptr
591590 # call FPTR function
@@ -619,7 +618,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_noncentral_chisquare(double df, double nonc
619618 return result
620619
621620
622- cpdef dparray dpnp_rng_normal(double loc, double scale, size):
621+ cpdef utils.dpnp_descriptor dpnp_rng_normal(double loc, double scale, size):
623622 """
624623 Returns an array populated with samples from normal distribution.
625624 `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):
628627 """
629628
630629 dtype = numpy.float64
631- cdef dparray result
630+ cdef dparray_shape_type result_shape
631+ cdef utils.dpnp_descriptor result
632632 cdef DPNPFuncType param1_type
633633 cdef DPNPFuncData kernel_data
634634 cdef fptr_dpnp_rng_normal_c_1out_t func
635635
636636 if scale == 0.0 :
637- result = dparray(size, dtype = dtype)
638- result.fill(loc)
637+ return dpnp_full(size, loc, dtype)
639638 else :
640639 # convert string type names (dparray.dtype) to C enum DPNPFuncType
641640 param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
642641
643642 # get the FPTR data structure
644643 kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_NORMAL, param1_type, param1_type)
645644
646- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
647645 # 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 )
649648
650649 func = < fptr_dpnp_rng_normal_c_1out_t > kernel_data.ptr
651650 # call FPTR function
@@ -680,7 +679,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_pareto(double alpha, size):
680679 return result
681680
682681
683- cpdef dparray dpnp_rng_poisson(double lam, size):
682+ cpdef utils.dpnp_descriptor dpnp_rng_poisson(double lam, size):
684683 """
685684 Returns an array populated with samples from Poisson distribution.
686685 `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):
690689 """
691690
692691 dtype = numpy.int32
693- cdef dparray result
692+ cdef dparray_shape_type result_shape
693+ cdef utils.dpnp_descriptor result
694694 cdef DPNPFuncType param1_type
695695 cdef DPNPFuncData kernel_data
696696 cdef fptr_dpnp_rng_poisson_c_1out_t func
697697
698698 if lam == 0 :
699- result = dparray(size, dtype = dtype)
700- result.fill(0 )
699+ return dpnp_full(size, 0 , dtype)
701700 else :
702701 # convert string type names (dparray.dtype) to C enum DPNPFuncType
703702 param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
704703
705704 # get the FPTR data structure
706705 kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_POISSON, param1_type, param1_type)
707706
708- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
709707 # 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 )
711710
712711 func = < fptr_dpnp_rng_poisson_c_1out_t > kernel_data.ptr
713712 # call FPTR function
@@ -794,7 +793,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_random(dims):
794793 return result
795794
796795
797- cpdef dparray dpnp_rng_rayleigh(double scale, size):
796+ cpdef utils.dpnp_descriptor dpnp_rng_rayleigh(double scale, size):
798797 """
799798 Returns an array populated with samples from Rayleigh distribution.
800799 `dpnp_rayleigh` generates a matrix filled with random floats sampled from a
@@ -803,24 +802,24 @@ cpdef dparray dpnp_rng_rayleigh(double scale, size):
803802 """
804803
805804 dtype = numpy.float64
806- cdef dparray result
805+ cdef dparray_shape_type result_shape
806+ cdef utils.dpnp_descriptor result
807807 cdef DPNPFuncType param1_type
808808 cdef DPNPFuncData kernel_data
809809 cdef fptr_dpnp_rng_rayleigh_c_1out_t func
810810
811811 if scale == 0.0 :
812- result = dparray(size, dtype = dtype)
813- result.fill(0.0 )
812+ return dpnp_full(size, 0.0 , dtype)
814813 else :
815814 # convert string type names (dparray.dtype) to C enum DPNPFuncType
816815 param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
817816
818817 # get the FPTR data structure
819818 kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_RAYLEIGH, param1_type, param1_type)
820819
821- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
822820 # 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 )
824823
825824 func = < fptr_dpnp_rng_rayleigh_c_1out_t > kernel_data.ptr
826825 # call FPTR function
@@ -920,7 +919,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_exponential(size):
920919 return result
921920
922921
923- cpdef dparray dpnp_rng_standard_gamma(double shape, size):
922+ cpdef utils.dpnp_descriptor dpnp_rng_standard_gamma(double shape, size):
924923 """
925924 Returns an array populated with samples from standard gamma distribution.
926925 `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):
929928 """
930929
931930 dtype = numpy.float64
932- cdef dparray result
931+ cdef dparray_shape_type result_shape
932+ cdef utils.dpnp_descriptor result
933933 cdef DPNPFuncType param1_type
934934 cdef DPNPFuncData kernel_data
935935 cdef fptr_dpnp_rng_standard_gamma_c_1out_t func
936936
937937 if shape == 0.0 :
938- result = dparray(size, dtype = dtype)
939- result.fill(0.0 )
938+ return dpnp_full(size, 0.0 , dtype)
940939 else :
941940 # convert string type names (dparray.dtype) to C enum DPNPFuncType
942941 param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
943942
944943 # get the FPTR data structure
945944 kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_STANDARD_GAMMA, param1_type, param1_type)
946945
947- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
948946 # 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 )
950949
951950 func = < fptr_dpnp_rng_standard_gamma_c_1out_t > kernel_data.ptr
952951 # call FPTR function
@@ -1030,7 +1029,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_triangular(double left, double mode, double
10301029 return result
10311030
10321031
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):
10341033 """
10351034 Returns an array populated with samples from standard uniform distribution.
10361035 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):
10391038
10401039 """
10411040
1042- cdef dparray result
1041+ cdef dparray_shape_type result_shape
1042+ cdef utils.dpnp_descriptor result
10431043 cdef DPNPFuncType param1_type
10441044 cdef DPNPFuncData kernel_data
10451045 cdef fptr_dpnp_rng_uniform_c_1out_t func
10461046
10471047 if low == high:
1048- result = dparray(size, dtype = dtype)
1049- result.fill(low)
1048+ return dpnp_full(size, low, dtype)
10501049 else :
10511050 # convert string type names (dparray.dtype) to C enum DPNPFuncType
10521051 param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
10531052
10541053 # get the FPTR data structure
10551054 kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_UNIFORM, param1_type, param1_type)
10561055
1057- result_type = dpnp_DPNPFuncType_to_dtype(< size_t > kernel_data.return_type)
10581056 # 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 )
10601059
10611060 func = < fptr_dpnp_rng_uniform_c_1out_t > kernel_data.ptr
10621061 # call FPTR function
0 commit comments