forked from Theano/libgpuarray
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnumpy_compat.h
More file actions
35 lines (28 loc) · 808 Bytes
/
numpy_compat.h
File metadata and controls
35 lines (28 loc) · 808 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/*
* But it allow faster conversion to this new library of existing code
*/
#ifndef GPUARRAY_NUMPY_COMPAT
#define GPUARRAY_NUMPY_COMPAT
static int PyGpuArray_NDIM(const PyGpuArrayObject *arr) {
return arr->ga.nd;
}
static const size_t *PyGpuArray_DIMS(const PyGpuArrayObject *arr) {
return arr->ga.dimensions;
}
static const ssize_t *PyGpuArray_STRIDES(const PyGpuArrayObject* arr) {
return arr->ga.strides;
}
static size_t PyGpuArray_DIM(const PyGpuArrayObject* arr, int n) {
return arr->ga.dimensions[n];
}
static ssize_t PyGpuArray_STRIDE(const PyGpuArrayObject* arr, int n) {
return arr->ga.strides[n];
}
static size_t PyGpuArray_SIZE(const PyGpuArrayObject* arr) {
size_t size = 1;
for(int i=0; i< arr->ga.nd; i++) {
size *= arr->ga.dimensions[i];
}
return size;
}
#endif