Commit 22c497dd authored by rusty1s's avatar rusty1s
Browse files

added getData macro

parent 8b5daa16
#include <TH/TH.h> #include <TH/TH.h>
#include "common.h"
#define THGreedy_ TH_CONCAT_3(TH,Real,Greedy) #define THGreedy_ TH_CONCAT_3(TH,Real,Greedy)
#define DATA(TENSOR) TENSOR->storage->data + TENSOR->storageOffset
#define TH_GREEDY_CLUSTER(cluster, row, col, deg, SELECT) { \ #define TH_GREEDY_CLUSTER(cluster, row, col, deg, SELECT) { \
THLongTensor_fill(cluster, -1); \ THLongTensor_fill(cluster, -1); \
int64_t *clusterData = DATA(cluster); \ int64_t *clusterData = THTensor_getData(cluster); \
int64_t *rowData = DATA(row); \ int64_t *rowData = THTensor_getData(row); \
int64_t *colData = DATA(col); \ int64_t *colData = THTensor_getData(col); \
int64_t *degData = DATA(deg); \ int64_t *degData = THTensor_getData(deg); \
ptrdiff_t rowIdx = 0, neighborIdx; \ ptrdiff_t rowIdx = 0, neighborIdx; \
int64_t rowValue, colValue, clusterValue, tmp; \ int64_t rowValue, colValue, clusterValue, tmp; \
while(rowIdx < THLongTensor_nElement(row)) { \ while(rowIdx < THLongTensor_nElement(row)) { \
......
#include <TH/TH.h> #include <TH/TH.h>
#include "common.h"
#define THGrid_ TH_CONCAT_3(TH,Real,Grid) #define THGrid_ TH_CONCAT_3(TH,Real,Grid)
#define DATA(TENSOR) TENSOR->storage->data + TENSOR->storageOffset
#include "generic/THGrid.c" #include "generic/THGrid.c"
#include "THGenerateAllTypes.h" #include "THGenerateAllTypes.h"
#ifndef TH_COMMON_INC
#define TH_COMMON_INC
#define THTensor_getData(TENSOR) TENSOR->storage->data + TENSOR->storageOffset
#endif // TH_COMMON_INC
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
void THGreedy_(THLongTensor *cluster, THLongTensor *row, THLongTensor *col, THLongTensor *deg, void THGreedy_(THLongTensor *cluster, THLongTensor *row, THLongTensor *col, THLongTensor *deg,
THTensor *weight) { THTensor *weight) {
real *weightData = DATA(weight); real *weightData = THTensor_getData(weight);
real maxWeight = 0, tmpWeight; real maxWeight = 0, tmpWeight;
TH_GREEDY_CLUSTER(cluster, row, col, deg, TH_GREEDY_CLUSTER(cluster, row, col, deg,
for (neighborIdx = rowIdx; neighborIdx < rowIdx + degData[rowValue]; neighborIdx++) { for (neighborIdx = rowIdx; neighborIdx < rowIdx + degData[rowValue]; neighborIdx++) {
......
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
#else #else
void THGrid_(THLongTensor *cluster, THTensor *pos, THTensor *size, THLongTensor *count) { void THGrid_(THLongTensor *cluster, THTensor *pos, THTensor *size, THLongTensor *count) {
int64_t *clusterData = DATA(cluster); int64_t *clusterData = THTensor_getData(cluster);
real *posData = DATA(pos); real *posData = THTensor_getData(pos);
real *sizeData = DATA(size); real *sizeData = THTensor_getData(size);
int64_t *countData = DATA(count); int64_t *countData = THTensor_getData(count);
ptrdiff_t n, d; int64_t coef, value; ptrdiff_t n, d; int64_t coef, value;
for (n = 0; n < THTensor_(size)(pos, 0); n++) { for (n = 0; n < THTensor_(size)(pos, 0); n++) {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment