Skip to content

Commit 4a033cd

Browse files
authored
Merge pull request #357 from abergeron/np112_strides
Change the definition of the contiguous flags to ignore strides on dimensions of size 1
2 parents 4da85f6 + e68d495 commit 4a033cd

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

src/gpuarray_array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,7 +1118,7 @@ int GpuArray_is_c_contiguous(const GpuArray *a) {
11181118
int i;
11191119

11201120
for (i = a->nd - 1; i >= 0; i--) {
1121-
if (a->strides[i] != (ssize_t)size) return 0;
1121+
if (a->strides[i] != (ssize_t)size && a->dimensions[i] != 1) return 0;
11221122
// We suppose that overflow will not happen since data has to fit in memory
11231123
size *= a->dimensions[i];
11241124
}
@@ -1130,7 +1130,7 @@ int GpuArray_is_f_contiguous(const GpuArray *a) {
11301130
unsigned int i;
11311131

11321132
for (i = 0; i < a->nd; i++) {
1133-
if (a->strides[i] != (ssize_t)size) return 0;
1133+
if (a->strides[i] != (ssize_t)size && a->dimensions[i] != 1) return 0;
11341134
// We suppose that overflow will not happen since data has to fit in memory
11351135
size *= a->dimensions[i];
11361136
}

0 commit comments

Comments
 (0)