Skip to content

Commit b92cb12

Browse files
committed
Resolves gh-1724
Moves `order` validation to the start of `_from_input_shape_strides`
1 parent f3c2975 commit b92cb12

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

dpctl/tensor/_stride_utils.pxi

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ cdef int _from_input_shape_strides(
7272
cdef Py_ssize_t* shape_arr
7373
cdef Py_ssize_t* strides_arr
7474

75+
if (int(order) not in [ord('C'), ord('F'), ord('c'), ord('f')]):
76+
return ERROR_INCORRECT_ORDER
77+
7578
# 0-d array
7679
if (nd == 0):
7780
contig[0] = (USM_ARRAY_C_CONTIGUOUS | USM_ARRAY_F_CONTIGUOUS)
@@ -109,10 +112,6 @@ cdef int _from_input_shape_strides(
109112
nelems[0] = elem_count
110113
if (strides is None):
111114
# no need to allocate and populate strides
112-
if (int(order) not in [ord('C'), ord('F'), ord('c'), ord('f')]):
113-
PyMem_Free(shape_ptr[0]);
114-
shape_ptr[0] = <Py_ssize_t *>(<size_t>0)
115-
return ERROR_INCORRECT_ORDER
116115
if order == <char> ord('C') or order == <char> ord('c'):
117116
contig[0] = USM_ARRAY_C_CONTIGUOUS
118117
else:

0 commit comments

Comments
 (0)