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
3b318ccb
Commit
3b318ccb
authored
Mar 30, 2018
by
rusty1s
Browse files
clean up
parent
81940250
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
50 additions
and
44 deletions
+50
-44
aten/TH/THGreedy.c
aten/TH/THGreedy.c
+8
-4
aten/TH/THGrid.c
aten/TH/THGrid.c
+1
-0
aten/TH/THGrid.h
aten/TH/THGrid.h
+28
-28
aten/TH/generic/THGreedy.c
aten/TH/generic/THGreedy.c
+1
-1
aten/TH/generic/THGrid.c
aten/TH/generic/THGrid.c
+12
-11
No files found.
aten/TH/THGreedy.c
View file @
3b318ccb
#include <TH/TH.h>
#define THGreedy_(NAME) TH_CONCAT_4(TH,Real,Greedy_,NAME)
#define DATA(TENSOR) TENSOR->storage->data + TENSOR->storageOffset
#define TH_GREEDY_CLUSTER(cluster, row, col, deg, SELECT) { \
int64_t *clusterData = cluster->storage->data + cluster->storageOffset; \
int64_t *rowData = row->storage->data + row->storageOffset; \
int64_t *colData = col->storage->data + col->storageOffset; \
int64_t *degData = deg->storage->data + deg->storageOffset; \
THLongTensor_fill(cluster, -1); \
int64_t *clusterData = DATA(cluster); \
int64_t *rowData = DATA(row); \
int64_t *colData = DATA(col); \
int64_t *degData = DATA(deg); \
ptrdiff_t rowIdx = 0, neighborIdx; \
int64_t rowValue, colValue, clusterValue, tmp; \
while(rowIdx < THLongTensor_nElement(row)) { \
rowValue = rowData[rowIdx]; \
printf("rowValue = %lli, ", rowValue); \
if (clusterData[rowValue] < 0) { \
colValue = rowValue; \
SELECT \
clusterValue = rowValue < colValue ? rowValue : colValue; \
printf("%lli", clusterValue); \
clusterData[rowValue] = clusterValue; \
clusterData[colValue] = clusterValue; \
} \
...
...
aten/TH/THGrid.c
View file @
3b318ccb
#include <TH/TH.h>
#define THGrid_(NAME) TH_CONCAT_4(TH,Real,Grid_,NAME)
#define DATA(TENSOR) TENSOR->storage->data + TENSOR->storageOffset
#include "generic/THGrid.c"
#include "THGenerateAllTypes.h"
aten/TH/THGrid.h
View file @
3b318ccb
void
THByteGrid
(
THLongTensor
*
cluster
,
THByteTensor
*
pos
,
THByteTensor
*
size
,
THLongTensor
*
count
);
void
THByteGrid
_cluster
(
THLongTensor
*
cluster
,
THByteTensor
*
pos
,
THByteTensor
*
size
,
THLongTensor
*
count
);
void
THCharGrid
(
THLongTensor
*
cluster
,
THCharTensor
*
pos
,
THCharTensor
*
size
,
THLongTensor
*
count
);
void
THCharGrid
_cluster
(
THLongTensor
*
cluster
,
THCharTensor
*
pos
,
THCharTensor
*
size
,
THLongTensor
*
count
);
void
THShortGrid
(
THLongTensor
*
cluster
,
THShortTensor
*
pos
,
THShortTensor
*
size
,
THLongTensor
*
count
);
void
THShortGrid
_cluster
(
THLongTensor
*
cluster
,
THShortTensor
*
pos
,
THShortTensor
*
size
,
THLongTensor
*
count
);
void
THIntGrid
(
THLongTensor
*
cluster
,
THIntTensor
*
pos
,
THIntTensor
*
size
,
THLongTensor
*
count
);
void
THIntGrid
_cluster
(
THLongTensor
*
cluster
,
THIntTensor
*
pos
,
THIntTensor
*
size
,
THLongTensor
*
count
);
void
THLongGrid
(
THLongTensor
*
cluster
,
THLongTensor
*
pos
,
THLongTensor
*
size
,
THLongTensor
*
count
);
void
THLongGrid
_cluster
(
THLongTensor
*
cluster
,
THLongTensor
*
pos
,
THLongTensor
*
size
,
THLongTensor
*
count
);
void
THFloatGrid
(
THLongTensor
*
cluster
,
THFloatTensor
*
pos
,
THFloatTensor
*
size
,
THLongTensor
*
count
);
void
THFloatGrid
_cluster
(
THLongTensor
*
cluster
,
THFloatTensor
*
pos
,
THFloatTensor
*
size
,
THLongTensor
*
count
);
void
THDoubleGrid
(
THLongTensor
*
cluster
,
THDoubleTensor
*
pos
,
THDoubleTensor
*
size
,
THLongTensor
*
count
);
void
THDoubleGrid
_cluster
(
THLongTensor
*
cluster
,
THDoubleTensor
*
pos
,
THDoubleTensor
*
size
,
THLongTensor
*
count
);
aten/TH/generic/THGreedy.c
View file @
3b318ccb
...
...
@@ -4,7 +4,7 @@
void
THGreedy_
(
cluster
)(
THLongTensor
*
cluster
,
THLongTensor
*
row
,
THLongTensor
*
col
,
THLongTensor
*
deg
,
THTensor
*
weight
)
{
real
*
weightData
=
weight
->
storage
->
data
+
weight
->
storageOffset
;
real
*
weightData
=
DATA
(
weight
)
;
real
maxWeight
=
0
,
tmpWeight
;
TH_GREEDY_CLUSTER
(
cluster
,
row
,
col
,
deg
,
for
(
neighborIdx
=
rowIdx
;
neighborIdx
<
rowIdx
+
degData
[
rowValue
];
neighborIdx
++
)
{
...
...
aten/TH/generic/THGrid.c
View file @
3b318ccb
...
...
@@ -3,20 +3,21 @@
#else
void
THGrid_
(
cluster
)(
THLongTensor
*
cluster
,
THTensor
*
pos
,
THTensor
*
size
,
THLongTensor
*
count
)
{
real
*
sizeData
=
size
->
storage
->
data
+
size
->
storageOffset
;
int64_t
*
countData
=
count
->
storage
->
data
+
count
->
storageOffset
;
int64_t
dims
=
THLongTensor_nElement
(
count
);
THLongTensor_unsqueeze1d
(
cluster
,
NULL
,
1
);
ptrdiff_t
d
;
int64_t
coef
,
value
;
TH_TENSOR_DIM_APPLY2
(
int64_t
,
cluster
,
real
,
pos
,
1
,
int64_t
*
clusterData
=
DATA
(
cluster
);
real
*
posData
=
DATA
(
pos
);
real
*
sizeData
=
DATA
(
size
);
int64_t
*
countData
=
DATA
(
count
);
ptrdiff_t
n
,
d
;
int64_t
coef
,
value
;
for
(
n
=
0
;
n
<
THTensor_
(
size
)(
pos
,
0
);
n
++
)
{
coef
=
1
;
value
=
0
;
for
(
d
=
0
;
d
<
dims
;
d
++
)
{
value
+=
coef
*
(
int64_t
)
(
*
(
pos
_d
ata
+
d
*
pos
_
stride
)
/
sizeData
[
d
]);
for
(
d
=
0
;
d
<
THTensor_
(
size
)(
pos
,
1
)
;
d
++
)
{
value
+=
coef
*
(
int64_t
)
(
*
(
pos
D
ata
+
d
*
pos
->
stride
[
1
]
)
/
sizeData
[
d
]);
coef
*=
countData
[
d
];
}
cluster_data
[
0
]
=
value
;
)
THLongTensor_squeeze1d
(
cluster
,
NULL
,
1
);
posData
+=
pos
->
stride
[
0
]
;
clusterData
[
n
]
=
value
;
}
}
#endif // TH_GENERIC_FILE
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