Commit 546db4dc authored by rusty1s's avatar rusty1s
Browse files

added serial cluster implementation (edge-wise), should ne however node-wise

parent d4cfecaa
......@@ -2,5 +2,20 @@
#define cluster_(NAME) TH_CONCAT_4(cluster_, NAME, _, Real)
void cluster_serial(THLongTensor *output, THLongTensor *row, THLongTensor *col) {
int64_t *output_data = output->storage->data + output->storageOffset;
int64_t *row_data = row->storage->data + row->storageOffset;
int64_t *col_data = col->storage->data + col->storageOffset;
int64_t n, N = THLongTensor_nElement(output), r, c, value;
for (n = 0; n < N; n++) {
r = row_data[n]; c = col_data[c];
if (output_data[r] == -1 && output_data[c] == -1) {
value = r < c ? r : c;
output_data[r] = value;
output_data[c] = value;
}
}
}
#include "generic/cpu.c"
#include "THGenerateAllTypes.h"
......@@ -5,3 +5,5 @@ void cluster_grid_Char (int C, THLongTensor *output, THCharTensor *position,
void cluster_grid_Short (int C, THLongTensor *output, THShortTensor *position, THShortTensor *size, THLongTensor *count);
void cluster_grid_Int (int C, THLongTensor *output, THIntTensor *position, THIntTensor *size, THLongTensor *count);
void cluster_grid_Long (int C, THLongTensor *output, THLongTensor *position, THLongTensor *size, THLongTensor *count);
void cluster_serial(THLongTensor *output, THLongTensor *row, THLongTensor *col);
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