THCGrid.cu 562 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
#include "THCGrid.h"

rusty1s's avatar
rusty1s committed
3
4
5
6
7
8
9
10
11
12
13
14
15
16
template<typename real, int dims>
__global__ void gridKernel(int64_t *cluster, TensorInfo<real> posInfo, real *size,
                           int64_t *count, const int nNodes) {
  KERNEL_LOOP(i, nNodes) {
    real *pos = posInfo->data + i * posInfo->stride[0];
    int64_t coef = 1, value = 0;
    for (ptrdiff_t d = 0; d < dims; d++) {
      value += coef * (int64_t) (pos[d * posInfo->stride[1]] / size[d]);
      coef *= count[d];
    }
    cluster[i] = value;
  }
}

rusty1s's avatar
rusty1s committed
17
18
#include "generic/THCGrid.cu"
#include "THC/THCGenerateAllTypes.h"