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
6b75d236
Commit
6b75d236
authored
Aug 22, 2018
by
rusty1s
Browse files
grid cpu
parent
878e1193
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
12 additions
and
15 deletions
+12
-15
cpu/grid.cpp
cpu/grid.cpp
+9
-10
setup.cfg
setup.cfg
+1
-1
test/test_grid.py
test/test_grid.py
+0
-0
torch_cluster/grid.py
torch_cluster/grid.py
+2
-4
No files found.
cpu/grid.cpp
View file @
6b75d236
...
...
@@ -2,18 +2,17 @@
at
::
Tensor
grid
(
at
::
Tensor
pos
,
at
::
Tensor
size
,
at
::
Tensor
start
,
at
::
Tensor
end
)
{
size
=
size
.
toType
(
pos
.
type
());
start
=
start
.
toType
(
pos
.
type
());
end
=
end
.
toType
(
pos
.
type
());
pos
=
pos
-
start
.
view
({
1
,
-
1
});
auto
num_voxels
=
((
end
-
start
)
/
size
).
toType
(
at
::
kLong
);
num_voxels
=
(
num_voxels
+
1
).
cumsum
(
0
);
num_voxels
-=
num_voxels
.
data
<
int64_t
>
()[
0
];
num_voxels
.
data
<
int64_t
>
()[
0
]
=
1
;
auto
cluster
=
pos
/
size
.
view
({
1
,
-
1
});
cluster
=
cluster
.
toType
(
at
::
kLong
);
auto
num_voxels
=
((
end
-
start
)
/
size
).
toType
(
at
::
kLong
)
+
1
;
num_voxels
=
num_voxels
.
cumprod
(
0
);
num_voxels
=
at
::
cat
({
at
::
ones
(
1
,
num_voxels
.
options
()),
num_voxels
},
0
);
auto
index
=
empty
(
size
.
size
(
0
),
num_voxels
.
options
());
arange_out
(
index
,
size
.
size
(
0
));
num_voxels
=
num_voxels
.
index_select
(
0
,
index
);
auto
cluster
=
(
pos
/
size
.
view
({
1
,
-
1
})).
toType
(
at
::
kLong
);
cluster
*=
num_voxels
.
view
({
1
,
-
1
});
cluster
=
cluster
.
sum
(
1
);
...
...
setup.cfg
View file @
6b75d236
...
...
@@ -5,4 +5,4 @@ description-file = README.md
test = pytest
[tool:pytest]
addopts = --capture=no
--cov
addopts = --capture=no
test/grid.py
→
test/
test_
grid.py
View file @
6b75d236
File moved
torch_cluster/grid.py
View file @
6b75d236
...
...
@@ -28,9 +28,7 @@ def grid_cluster(pos, size, start=None, end=None):
start
=
pos
.
t
().
min
(
dim
=
1
)[
0
]
if
start
is
None
else
start
end
=
pos
.
t
().
max
(
dim
=
1
)[
0
]
if
end
is
None
else
end
if
pos
.
is_cuda
:
cluster
=
grid_cuda
.
grid
(
pos
,
size
,
start
,
end
)
else
:
cluster
=
grid_cpu
.
grid
(
pos
,
size
,
start
,
end
)
op
=
grid_cuda
.
grid
if
pos
.
is_cuda
else
grid_cpu
.
grid
cluster
=
op
(
pos
,
size
,
start
,
end
)
return
cluster
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