"megatron/git@developer.sourcefind.cn:OpenDAS/megatron-lm.git" did not exist on "88637044bee2e95a96c3f0a3a1e9022ace330ea9"
Commit cb1b4b1a authored by rusty1s's avatar rusty1s
Browse files

added comments

parent 4056bf63
...@@ -8,20 +8,23 @@ void cluster_random(THLongTensor *output, THLongTensor *row, THLongTensor *col, ...@@ -8,20 +8,23 @@ void cluster_random(THLongTensor *output, THLongTensor *row, THLongTensor *col,
int64_t *col_data = col->storage->data + col->storageOffset; int64_t *col_data = col->storage->data + col->storageOffset;
int64_t *degree_data = degree->storage->data + degree->storageOffset; int64_t *degree_data = degree->storage->data + degree->storageOffset;
int64_t e = 0, row_value, col_value, i; int64_t e = 0, row_value, col_value, i, value;
while(e < THLongTensor_nElement(row)) { while(e < THLongTensor_nElement(row)) {
row_value = row_data[e]; row_value = row_data[e];
if (output_data[row_value] < 0) { // Node is unmatched. if (output_data[row_value] < 0) { // Node is unmatched.
// Find next unmatched neighbor. // Find next unmatched neighbor.
col_value = -1; col_value = -1;
for (i = 0; i < degree_data[row_value]; i++) { for (i = 0; i < degree_data[row_value]; i++) {
col_value = col_data[e + i]; value = col_data[e + i];
if (output_data[col_value] < 0) break; // Neighbor found. if (output_data[value] < 0) { // Neighbor found. Save and abort.
else col_value = -1; col_value = value;
break;
}
} }
// Set output. // Set cluster output for new matched nodes (one or two).
if (col_value < 0) { if (col_value < 0) {
output_data[row_value] = row_value; output_data[row_value] = row_value;
} }
...@@ -31,6 +34,8 @@ void cluster_random(THLongTensor *output, THLongTensor *row, THLongTensor *col, ...@@ -31,6 +34,8 @@ void cluster_random(THLongTensor *output, THLongTensor *row, THLongTensor *col,
output_data[col_value] = i; output_data[col_value] = i;
} }
} }
// Jump to next row.
e += degree_data[row_value]; e += degree_data[row_value];
} }
} }
......
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