@@ -7,9 +7,6 @@ int APPLY_SPECIFIC(cpu_dimshuffle)(PyArrayObject *input, PyArrayObject **res, PA
7
7
npy_intp * dimensions ;
8
8
npy_intp * strides ;
9
9
10
- // This points to either the original input or a copy we create below.
11
- // Either way, this is what we should be working on/with.
12
- PyArrayObject * _input ;
13
10
14
11
if (!PyArray_IS_C_CONTIGUOUS (params -> _new_order )) {
15
12
PyErr_SetString (PyExc_RuntimeError , "DimShuffle: param _new_order must be C-contiguous." );
@@ -34,12 +31,12 @@ int APPLY_SPECIFIC(cpu_dimshuffle)(PyArrayObject *input, PyArrayObject **res, PA
34
31
return 1 ;
35
32
};
36
33
37
- npy_intp original_size = PyArray_SIZE (_input );
34
+ npy_intp original_size = PyArray_SIZE (input );
38
35
npy_intp new_size = 1 ;
39
36
for (npy_intp i = 0 ; i < nd_out ; ++ i ) {
40
37
if (new_order [i ] != -1 ) {
41
- dimensions [i ] = PyArray_DIMS (_input )[new_order [i ]];
42
- strides [i ] = PyArray_DIMS (_input )[new_order [i ]] == 1 ? 0 : PyArray_STRIDES (_input )[new_order [i ]];
38
+ dimensions [i ] = PyArray_DIMS (input )[new_order [i ]];
39
+ strides [i ] = PyArray_DIMS (input )[new_order [i ]] == 1 ? 0 : PyArray_STRIDES (input )[new_order [i ]];
43
40
} else {
44
41
dimensions [i ] = 1 ;
45
42
strides [i ] = 0 ;
@@ -57,22 +54,15 @@ int APPLY_SPECIFIC(cpu_dimshuffle)(PyArrayObject *input, PyArrayObject **res, PA
57
54
if (* res )
58
55
Py_XDECREF (* res );
59
56
60
- if (params -> inplace ) {
61
- _input = input ;
62
- Py_INCREF ((PyObject * )_input );
63
- } else {
64
- _input = (PyArrayObject * )PyArray_FromAny (
65
- (PyObject * )input , NULL , 0 , 0 , NPY_ARRAY_ALIGNED | NPY_ARRAY_ENSURECOPY ,
66
- NULL );
67
- }
57
+ Py_INCREF ((PyObject * )input );
68
58
69
59
// Create the new array.
70
60
* res = (PyArrayObject * )PyArray_New (& PyArray_Type , nd_out , dimensions ,
71
- PyArray_TYPE (_input ), strides ,
72
- PyArray_DATA (_input ), PyArray_ITEMSIZE (_input ),
61
+ PyArray_TYPE (input ), strides ,
62
+ PyArray_DATA (input ), PyArray_ITEMSIZE (input ),
73
63
// borrow only the writable flag from the base
74
64
// the NPY_OWNDATA flag will default to 0.
75
- (NPY_ARRAY_WRITEABLE * PyArray_ISWRITEABLE (_input )),
65
+ (NPY_ARRAY_WRITEABLE * PyArray_ISWRITEABLE (input )),
76
66
NULL );
77
67
78
68
if (* res == NULL ) {
@@ -85,7 +75,7 @@ int APPLY_SPECIFIC(cpu_dimshuffle)(PyArrayObject *input, PyArrayObject **res, PA
85
75
PyArray_UpdateFlags (* res , NPY_ARRAY_UPDATE_ALL );
86
76
87
77
// we are making a view in both inplace and non-inplace cases
88
- PyArray_SetBaseObject (* res , (PyObject * )_input );
78
+ PyArray_SetBaseObject (* res , (PyObject * )input );
89
79
90
80
free (strides );
91
81
free (dimensions );
0 commit comments