Skip to content

Commit b056411

Browse files
committed
Remove arange() from cython path
1 parent 4c903f6 commit b056411

File tree

4 files changed

+33
-55
lines changed

4 files changed

+33
-55
lines changed

dpnp/backend/include/dpnp_iface_fptr.hpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -69,7 +69,6 @@ enum class DPNPFuncName : size_t
6969
DPNP_FN_ANY, /**< Used in numpy.any() impl */
7070
DPNP_FN_ANY_EXT, /**< Used in numpy.any() impl, requires extra parameters */
7171
DPNP_FN_ARANGE, /**< Used in numpy.arange() impl */
72-
DPNP_FN_ARANGE_EXT, /**< Used in numpy.arange() impl, requires extra parameters */
7372
DPNP_FN_ARCCOS, /**< Used in numpy.arccos() impl */
7473
DPNP_FN_ARCCOS_EXT, /**< Used in numpy.arccos() impl, requires extra parameters */
7574
DPNP_FN_ARCCOSH, /**< Used in numpy.arccosh() impl */

dpnp/backend/kernels/dpnp_krnl_arraycreation.cpp

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -90,18 +90,41 @@ void dpnp_arange_c(size_t start, size_t step, void* result1, size_t size)
9090
size,
9191
dep_event_vec_ref);
9292
DPCTLEvent_WaitAndThrow(event_ref);
93+
DPCTLEvent_Delete(event_ref);
9394
}
9495

9596
template <typename _DataType>
9697
void (*dpnp_arange_default_c)(size_t, size_t, void*, size_t) = dpnp_arange_c<_DataType>;
9798

98-
template <typename _DataType>
99-
DPCTLSyclEventRef (*dpnp_arange_ext_c)(DPCTLSyclQueueRef,
100-
size_t,
101-
size_t,
102-
void*,
103-
size_t,
104-
const DPCTLEventVectorRef) = dpnp_arange_c<_DataType>;
99+
// Explicit instantiation of the function, since dpnp_arange_c() is used by other template functions,
100+
// but implicit instantiation is not applied anymore.
101+
template DPCTLSyclEventRef dpnp_arange_c<int32_t>(DPCTLSyclQueueRef,
102+
size_t,
103+
size_t,
104+
void*,
105+
size_t,
106+
const DPCTLEventVectorRef);
107+
108+
template DPCTLSyclEventRef dpnp_arange_c<int64_t>(DPCTLSyclQueueRef,
109+
size_t,
110+
size_t,
111+
void*,
112+
size_t,
113+
const DPCTLEventVectorRef);
114+
115+
template DPCTLSyclEventRef dpnp_arange_c<float>(DPCTLSyclQueueRef,
116+
size_t,
117+
size_t,
118+
void*,
119+
size_t,
120+
const DPCTLEventVectorRef);
121+
122+
template DPCTLSyclEventRef dpnp_arange_c<double>(DPCTLSyclQueueRef,
123+
size_t,
124+
size_t,
125+
void*,
126+
size_t,
127+
const DPCTLEventVectorRef);
105128

106129
template <typename _DataType>
107130
DPCTLSyclEventRef dpnp_diag_c(DPCTLSyclQueueRef q_ref,
@@ -1287,11 +1310,6 @@ void func_map_init_arraycreation(func_map_t& fmap)
12871310
fmap[DPNPFuncName::DPNP_FN_ARANGE][eft_FLT][eft_FLT] = {eft_FLT, (void*)dpnp_arange_default_c<float>};
12881311
fmap[DPNPFuncName::DPNP_FN_ARANGE][eft_DBL][eft_DBL] = {eft_DBL, (void*)dpnp_arange_default_c<double>};
12891312

1290-
fmap[DPNPFuncName::DPNP_FN_ARANGE_EXT][eft_INT][eft_INT] = {eft_INT, (void*)dpnp_arange_ext_c<int32_t>};
1291-
fmap[DPNPFuncName::DPNP_FN_ARANGE_EXT][eft_LNG][eft_LNG] = {eft_LNG, (void*)dpnp_arange_ext_c<int64_t>};
1292-
fmap[DPNPFuncName::DPNP_FN_ARANGE_EXT][eft_FLT][eft_FLT] = {eft_FLT, (void*)dpnp_arange_ext_c<float>};
1293-
fmap[DPNPFuncName::DPNP_FN_ARANGE_EXT][eft_DBL][eft_DBL] = {eft_DBL, (void*)dpnp_arange_ext_c<double>};
1294-
12951313
fmap[DPNPFuncName::DPNP_FN_DIAG][eft_INT][eft_INT] = {eft_INT, (void*)dpnp_diag_default_c<int32_t>};
12961314
fmap[DPNPFuncName::DPNP_FN_DIAG][eft_LNG][eft_LNG] = {eft_LNG, (void*)dpnp_diag_default_c<int64_t>};
12971315
fmap[DPNPFuncName::DPNP_FN_DIAG][eft_FLT][eft_FLT] = {eft_FLT, (void*)dpnp_diag_default_c<float>};

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
4545
DPNP_FN_ANY
4646
DPNP_FN_ANY_EXT
4747
DPNP_FN_ARANGE
48-
DPNP_FN_ARANGE_EXT
4948
DPNP_FN_ARCCOS
5049
DPNP_FN_ARCCOS_EXT
5150
DPNP_FN_ARCCOSH
@@ -519,7 +518,6 @@ cpdef dpnp_descriptor dpnp_matmul(dpnp_descriptor in_array1, dpnp_descriptor in_
519518
"""
520519
Array creation routines
521520
"""
522-
cpdef dpnp_descriptor dpnp_arange(start, stop, step, dtype)
523521
cpdef dpnp_descriptor dpnp_init_val(shape, dtype, value)
524522
cpdef dpnp_descriptor dpnp_full(result_shape, value_in, result_dtype) # same as dpnp_init_val
525523
cpdef dpnp_descriptor dpnp_copy(dpnp_descriptor x1)

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 1 addition & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2020, Intel Corporation
4+
# Copyright (c) 2016-2022, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without
@@ -50,7 +50,6 @@ import numpy
5050

5151

5252
__all__ = [
53-
"dpnp_arange",
5453
"dpnp_astype",
5554
"dpnp_flatten",
5655
"dpnp_init_val",
@@ -74,9 +73,6 @@ include "dpnp_algo_statistics.pyx"
7473
include "dpnp_algo_trigonometric.pyx"
7574

7675

77-
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_arange_t)(c_dpctl.DPCTLSyclQueueRef,
78-
size_t, size_t, void *, size_t,
79-
const c_dpctl.DPCTLEventVectorRef)
8076
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_astype_t)(c_dpctl.DPCTLSyclQueueRef,
8177
const void *, void * , const size_t,
8278
const c_dpctl.DPCTLEventVectorRef)
@@ -92,39 +88,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_initval_t)(c_dpctl.DPCTLSyclQueueR
9288
const c_dpctl.DPCTLEventVectorRef)
9389

9490

95-
cpdef utils.dpnp_descriptor dpnp_arange(start, stop, step, dtype):
96-
obj_len = int(numpy.ceil((stop - start) / step))
97-
if obj_len < 0:
98-
raise ValueError(f"DPNP dpnp_arange(): Negative array size (start={start},stop={stop},step={step})")
99-
100-
cdef tuple obj_shape = utils._object_to_tuple(obj_len)
101-
102-
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dtype)
103-
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_ARANGE_EXT, param1_type, param1_type)
104-
105-
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(obj_shape, kernel_data.return_type, None)
106-
107-
# for i in range(result.size):
108-
# result[i] = start + i
109-
110-
result_sycl_queue = result.get_array().sycl_queue
111-
112-
cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
113-
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
114-
115-
cdef fptr_dpnp_arange_t func = <fptr_dpnp_arange_t > kernel_data.ptr
116-
cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
117-
start,
118-
step,
119-
result.get_data(),
120-
result.size,
121-
NULL) # dep_events_ref)
122-
with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
123-
c_dpctl.DPCTLEvent_Delete(event_ref)
124-
125-
return result
126-
127-
12891
cpdef utils.dpnp_descriptor dpnp_astype(utils.dpnp_descriptor x1, dtype):
12992
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)
13093
cdef DPNPFuncType param2_type = dpnp_dtype_to_DPNPFuncType(dtype)

0 commit comments

Comments
 (0)