File: numpy_compat.h

package info (click to toggle)
libgpuarray 0.7.6-13
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,176 kB
  • sloc: ansic: 19,235; python: 4,591; makefile: 208; javascript: 71; sh: 15
file content (35 lines) | stat: -rw-r--r-- 808 bytes parent folder | download | duplicates (3)
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