Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-cluster
Commits
acbdd5db
Commit
acbdd5db
authored
Mar 31, 2018
by
rusty1s
Browse files
greedy cpu without degree computation: results in O(E) runtime :(
parent
878fa61f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
39 deletions
+35
-39
aten/TH/THGreedy.c
aten/TH/THGreedy.c
+21
-21
aten/TH/THGreedy.h
aten/TH/THGreedy.h
+8
-8
aten/TH/generic/THGreedy.c
aten/TH/generic/THGreedy.c
+6
-10
No files found.
aten/TH/THGreedy.c
View file @
acbdd5db
...
@@ -4,36 +4,36 @@
...
@@ -4,36 +4,36 @@
#define THGreedy_ TH_CONCAT_3(TH,Real,Greedy)
#define THGreedy_ TH_CONCAT_3(TH,Real,Greedy)
#define TH_GREEDY_CLUSTER(cluster, row, col,
deg,
SELECT) { \
#define TH_GREEDY_CLUSTER(cluster, row, col, SELECT) { \
THLongTensor_fill(cluster, -1); \
THLongTensor_fill(cluster, -1); \
int64_t *clusterData = THTensor_getData(cluster); \
int64_t *clusterData = THTensor_getData(cluster); \
int64_t *rowData = THTensor_getData(row); \
int64_t *rowData = THTensor_getData(row); \
int64_t *colData = THTensor_getData(col); \
int64_t *colData = THTensor_getData(col); \
int64_t *degData
= THTensor_
getData(deg
); \
ptrdiff_t idx = 0, nEdges
= TH
Long
Tensor_
nElement(row
); \
ptrdiff_t rowIdx = 0, neighborIdx
; \
int64_t rowValue, pairValue, colValue, clusterValue
; \
int64_t rowValue, colValue, clusterValue, tmp;
\
while(idx < nEdges) {
\
while(rowIdx < THLongTensor_nElement(row)) {
\
rowValue = rowData[idx];
\
row
Value = row
Data[rowIdx]
; \
pair
Value = row
Value
; \
if (clusterData[rowValue] < 0) { \
if (clusterData[rowValue] < 0) { \
colValue = rowValue; \
while(idx < nEdges && rowData[idx] == rowValue) { \
SELECT \
colValue = colData[idx]; \
clusterValue = rowValue < colValue ? rowValue : colValue; \
if (clusterData[colValue] < 0) { \
clusterData[rowValue] = clusterValue; \
SELECT \
clusterData[colValue] = clusterValue; \
} \
idx++; \
} \
} \
} \
rowIdx += degData[rowValue]; \
clusterValue = rowValue < pairValue ? rowValue : pairValue; \
clusterData[rowValue] = clusterValue; \
clusterData[pairValue] = clusterValue; \
while(idx < nEdges && rowData[idx] == rowValue) idx++; \
} \
} \
}
}
void
THGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
)
{
void
THGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
)
{
TH_GREEDY_CLUSTER
(
cluster
,
row
,
col
,
deg
,
TH_GREEDY_CLUSTER
(
cluster
,
row
,
col
,
for
(
neighborIdx
=
rowIdx
;
neighborIdx
<
rowIdx
+
degData
[
rowValue
];
neighborIdx
++
)
{
pairValue
=
colValue
;
tmp
=
colData
[
neighborIdx
];
break
;
if
(
clusterData
[
tmp
]
<
0
)
{
colValue
=
tmp
;
break
;
}
}
)
)
}
}
...
...
aten/TH/THGreedy.h
View file @
acbdd5db
void
THGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
);
void
THGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
);
void
THByteGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THByteTensor
*
weight
);
void
THByteGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THByteTensor
*
weight
);
void
THCharGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THCharTensor
*
weight
);
void
THCharGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THCharTensor
*
weight
);
void
THShortGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THShortTensor
*
weight
);
void
THShortGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THShortTensor
*
weight
);
void
THIntGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THIntTensor
*
weight
);
void
THIntGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THIntTensor
*
weight
);
void
THLongGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THLongTensor
*
weight
);
void
THLongGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
weight
);
void
THFloatGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THFloatTensor
*
weight
);
void
THFloatGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THFloatTensor
*
weight
);
void
THDoubleGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THDoubleTensor
*
weight
);
void
THDoubleGreedy
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THDoubleTensor
*
weight
);
aten/TH/generic/THGreedy.c
View file @
acbdd5db
...
@@ -2,18 +2,14 @@
...
@@ -2,18 +2,14 @@
#define TH_GENERIC_FILE "generic/THGreedy.c"
#define TH_GENERIC_FILE "generic/THGreedy.c"
#else
#else
void
THGreedy_
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
void
THGreedy_
(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THTensor
*
weight
)
{
THTensor
*
weight
)
{
real
*
weightData
=
THTensor_getData
(
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
,
for
(
neighborIdx
=
rowIdx
;
neighborIdx
<
rowIdx
+
degData
[
rowValue
];
neighborIdx
++
)
{
tmpWeight
=
weightData
[
idx
];
tmp
=
colData
[
neighborIdx
];
if
(
tmpWeight
>
maxWeight
)
{
tmpWeight
=
weightData
[
neighborIdx
];
pairValue
=
colValue
;
if
(
clusterData
[
tmp
]
<
0
&&
tmpWeight
>
maxWeight
)
{
maxWeight
=
tmpWeight
;
colValue
=
tmp
;
maxWeight
=
tmpWeight
;
}
}
}
)
)
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment