Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
one
spconv
Commits
5759db44
Commit
5759db44
authored
Nov 17, 2021
by
yan.yan
Browse files
small changes, publish v2.1.8 prebuilts
parent
1a333c99
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
23 additions
and
12 deletions
+23
-12
README.md
README.md
+3
-1
example/voxel_gen.py
example/voxel_gen.py
+8
-4
spconv/pytorch/__init__.py
spconv/pytorch/__init__.py
+10
-6
spconv/pytorch/core.py
spconv/pytorch/core.py
+2
-1
No files found.
README.md
View file @
5759db44
...
@@ -34,7 +34,7 @@
...
@@ -34,7 +34,7 @@
[

](https://github.com/traveller59/spconv/actions?query=workflow%3Abuild)
[

](https://github.com/traveller59/spconv/actions?query=workflow%3Abuild)
| | PyP
i
| Install |Downloads |
| | PyP
I
| Install |Downloads |
| -------------- |:---------------------:| ---------------------:| ---------------------:|
| -------------- |:---------------------:| ---------------------:| ---------------------:|
| CPU (Linux Only) |
[
![PyPI Version
][
pypi-ver-cpu
]
]
[
pypi-url-cpu] | ```pip install spconv``` | [![pypi monthly download
][
pypi-download-cpu
]
][pypi-url-cpu] |
| CPU (Linux Only) |
[
![PyPI Version
][
pypi-ver-cpu
]
]
[
pypi-url-cpu] | ```pip install spconv``` | [![pypi monthly download
][
pypi-download-cpu
]
][pypi-url-cpu] |
| CUDA 10.2 |
[
![PyPI Version
][
pypi-ver-102
]
]
[
pypi-url-102] | ```pip install spconv-cu102``` | [![pypi monthly download
][
pypi-download-102
]
][pypi-url-102] |
| CUDA 10.2 |
[
![PyPI Version
][
pypi-ver-102
]
]
[
pypi-url-102] | ```pip install spconv-cu102``` | [![pypi monthly download
][
pypi-download-102
]
][pypi-url-102] |
...
@@ -66,6 +66,8 @@ Spconv 1.x users **NEED READ [THIS](docs/SPCONV_2_BREAKING_CHANGEs.md)** before
...
@@ -66,6 +66,8 @@ Spconv 1.x users **NEED READ [THIS](docs/SPCONV_2_BREAKING_CHANGEs.md)** before
## Spconv 2.x Development and Roadmap
## Spconv 2.x Development and Roadmap
Spconv 2.2 development has started. See [this issue](https://github.com/traveller59/spconv/issues/380) for more details.
See [dev plan](docs/SPCONV_DEVELOP_PLAN.md). A complete guide of spconv development will be released soon.
See [dev plan](docs/SPCONV_DEVELOP_PLAN.md). A complete guide of spconv development will be released soon.
## Usage
## Usage
...
...
example/voxel_gen.py
View file @
5759db44
...
@@ -21,6 +21,7 @@ import torch
...
@@ -21,6 +21,7 @@ import torch
def
main
():
def
main
():
np
.
random
.
seed
(
50051
)
# voxel gen source code: spconv/csrc/sparse/pointops.py
# voxel gen source code: spconv/csrc/sparse/pointops.py
gen
=
Point2VoxelCPU3d
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
gen
=
Point2VoxelCPU3d
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
coors_range_xyz
=
[
-
80
,
-
80
,
-
2
,
80
,
80
,
6
],
coors_range_xyz
=
[
-
80
,
-
80
,
-
2
,
80
,
80
,
6
],
...
@@ -36,7 +37,7 @@ def main():
...
@@ -36,7 +37,7 @@ def main():
voxels_np
=
voxels_tv
.
numpy_view
()
voxels_np
=
voxels_tv
.
numpy_view
()
indices_np
=
indices_tv
.
numpy_view
()
indices_np
=
indices_tv
.
numpy_view
()
num_p_in_vx_np
=
num_p_in_vx_tv
.
numpy_view
()
num_p_in_vx_np
=
num_p_in_vx_tv
.
numpy_view
()
print
(
"------Raw Voxels-------"
)
print
(
f
"------Raw Voxels
{
voxels_np
.
shape
[
0
]
}
-------"
)
print
(
voxels_np
[
0
])
print
(
voxels_np
[
0
])
# run voxel gen and FILL MEAN VALUE to voxel remain
# run voxel gen and FILL MEAN VALUE to voxel remain
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
.
point_to_voxel_empty_mean
(
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
.
point_to_voxel_empty_mean
(
...
@@ -49,6 +50,7 @@ def main():
...
@@ -49,6 +50,7 @@ def main():
def
main_point_with_features
():
def
main_point_with_features
():
np
.
random
.
seed
(
50051
)
# voxel gen source code: spconv/csrc/sparse/pointops.py
# voxel gen source code: spconv/csrc/sparse/pointops.py
gen
=
Point2VoxelCPU3d
(
gen
=
Point2VoxelCPU3d
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
...
@@ -68,7 +70,7 @@ def main_point_with_features():
...
@@ -68,7 +70,7 @@ def main_point_with_features():
voxels_np
=
voxels_tv
.
numpy_view
()
voxels_np
=
voxels_tv
.
numpy_view
()
indices_np
=
indices_tv
.
numpy_view
()
indices_np
=
indices_tv
.
numpy_view
()
num_p_in_vx_np
=
num_p_in_vx_tv
.
numpy_view
()
num_p_in_vx_np
=
num_p_in_vx_tv
.
numpy_view
()
print
(
"------Raw Voxels-------"
)
print
(
f
"------Raw Voxels
{
voxels_np
.
shape
[
0
]
}
-------"
)
print
(
voxels_np
[
0
])
print
(
voxels_np
[
0
])
# run voxel gen and FILL MEAN VALUE to voxel remain
# run voxel gen and FILL MEAN VALUE to voxel remain
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
.
point_to_voxel_empty_mean
(
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
.
point_to_voxel_empty_mean
(
...
@@ -81,6 +83,7 @@ def main_point_with_features():
...
@@ -81,6 +83,7 @@ def main_point_with_features():
def
main_pytorch_voxel_gen
():
def
main_pytorch_voxel_gen
():
np
.
random
.
seed
(
50051
)
# voxel gen source code: spconv/csrc/sparse/pointops.py
# voxel gen source code: spconv/csrc/sparse/pointops.py
gen
=
PointToVoxel
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
gen
=
PointToVoxel
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
coors_range_xyz
=
[
-
80
,
-
80
,
-
2
,
80
,
80
,
6
],
coors_range_xyz
=
[
-
80
,
-
80
,
-
2
,
80
,
80
,
6
],
...
@@ -94,7 +97,7 @@ def main_pytorch_voxel_gen():
...
@@ -94,7 +97,7 @@ def main_pytorch_voxel_gen():
voxels_np
=
voxels_th
.
numpy
()
voxels_np
=
voxels_th
.
numpy
()
indices_np
=
indices_th
.
numpy
()
indices_np
=
indices_th
.
numpy
()
num_p_in_vx_np
=
num_p_in_vx_th
.
numpy
()
num_p_in_vx_np
=
num_p_in_vx_th
.
numpy
()
print
(
"------Raw Voxels-------"
)
print
(
f
"------Raw Voxels
{
voxels_np
.
shape
[
0
]
}
-------"
)
print
(
voxels_np
[
0
])
print
(
voxels_np
[
0
])
# run voxel gen and FILL MEAN VALUE to voxel remain
# run voxel gen and FILL MEAN VALUE to voxel remain
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
(
pc_th
,
empty_mean
=
True
)
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
(
pc_th
,
empty_mean
=
True
)
...
@@ -106,6 +109,7 @@ def main_pytorch_voxel_gen():
...
@@ -106,6 +109,7 @@ def main_pytorch_voxel_gen():
def
main_pytorch_voxel_gen_cuda
():
def
main_pytorch_voxel_gen_cuda
():
np
.
random
.
seed
(
50051
)
# voxel gen source code: spconv/csrc/sparse/pointops.py
# voxel gen source code: spconv/csrc/sparse/pointops.py
device
=
torch
.
device
(
"cuda:0"
)
device
=
torch
.
device
(
"cuda:0"
)
gen
=
PointToVoxel
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
gen
=
PointToVoxel
(
vsize_xyz
=
[
0.1
,
0.1
,
0.1
],
...
@@ -121,7 +125,7 @@ def main_pytorch_voxel_gen_cuda():
...
@@ -121,7 +125,7 @@ def main_pytorch_voxel_gen_cuda():
voxels_np
=
voxels_th
.
cpu
().
numpy
()
voxels_np
=
voxels_th
.
cpu
().
numpy
()
indices_np
=
indices_th
.
cpu
().
numpy
()
indices_np
=
indices_th
.
cpu
().
numpy
()
num_p_in_vx_np
=
num_p_in_vx_th
.
cpu
().
numpy
()
num_p_in_vx_np
=
num_p_in_vx_th
.
cpu
().
numpy
()
print
(
"------Raw Voxels-------"
)
print
(
f
"------Raw Voxels
{
voxels_np
.
shape
[
0
]
}
-------"
)
print
(
voxels_np
[
0
])
print
(
voxels_np
[
0
])
# run voxel gen and FILL MEAN VALUE to voxel remain
# run voxel gen and FILL MEAN VALUE to voxel remain
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
(
pc_th
,
empty_mean
=
True
)
voxels_tv
,
indices_tv
,
num_p_in_vx_tv
=
gen
(
pc_th
,
empty_mean
=
True
)
...
...
spconv/pytorch/__init__.py
View file @
5759db44
...
@@ -3,17 +3,21 @@ from pathlib import Path
...
@@ -3,17 +3,21 @@ from pathlib import Path
import
numpy
as
np
import
numpy
as
np
import
torch
import
torch
from
spconv.pytorch
import
functional
,
ops
from
spconv.pytorch
import
ops
,
functional
from
spconv.pytorch
.conv
import
(
SparseConv1d
,
SparseConv2d
,
SparseConv3d
,
from
spconv.pytorch.conv
import
(
SparseConv
2
d
,
SparseConv
3
d
,
SparseConv
4
d
,
SparseConv
Transpose1
d
,
SparseConvTranspose2d
,
SparseConvTranspose3d
,
SparseConvTranspose2d
,
SparseConvTranspose3d
,
SparseConvTranspose4d
,
SparseInverseConv1d
,
SparseInverseConv2d
,
SparseInverseConv3d
,
SparseInverseConv2d
,
SparseInverseConv3d
,
SubMConv2d
,
SubMConv3d
)
SparseInverseConv4d
,
SubMConv1d
,
SubMConv2d
,
SubMConv3d
,
SubMConv4d
)
from
spconv.pytorch.core
import
SparseConvTensor
from
spconv.pytorch.core
import
SparseConvTensor
from
spconv.pytorch.identity
import
Identity
from
spconv.pytorch.identity
import
Identity
from
spconv.pytorch.modules
import
SparseModule
,
SparseSequential
,
assign_name_for_sparse_modules
from
spconv.pytorch.modules
import
(
SparseModule
,
SparseSequential
,
assign_name_for_sparse_modules
)
from
spconv.pytorch.ops
import
ConvAlgo
from
spconv.pytorch.ops
import
ConvAlgo
from
spconv.pytorch.pool
import
SparseMaxPool2d
,
SparseMaxPool3d
from
spconv.pytorch.pool
import
(
SparseMaxPool1d
,
SparseMaxPool2d
,
SparseMaxPool3d
,
SparseMaxPool4d
)
from
spconv.pytorch.tables
import
AddTable
,
ConcatTable
,
JoinTable
from
spconv.pytorch.tables
import
AddTable
,
ConcatTable
,
JoinTable
...
...
spconv/pytorch/core.py
View file @
5759db44
...
@@ -140,10 +140,11 @@ class SparseConvTensor(metaclass=SpConvTensorMeta):
...
@@ -140,10 +140,11 @@ class SparseConvTensor(metaclass=SpConvTensorMeta):
self
.
thrust_allocator
=
ThrustSortAllocator
(
features
.
device
)
self
.
thrust_allocator
=
ThrustSortAllocator
(
features
.
device
)
self
.
_timer
=
CUDAKernelTimer
(
enable_timer
)
self
.
_timer
=
CUDAKernelTimer
(
enable_timer
)
def
replace_feature
(
self
,
feature
):
def
replace_feature
(
self
,
feature
:
torch
.
Tensor
):
"""we need to replace x.features = F.relu(x.features) with x = x.replace_feature(F.relu(x.features))
"""we need to replace x.features = F.relu(x.features) with x = x.replace_feature(F.relu(x.features))
due to limit of torch.fx
due to limit of torch.fx
"""
"""
assert
feature
.
shape
[
0
]
==
self
.
indices
.
shape
[
0
],
"replaced num of features not equal to indices"
new_spt
=
SparseConvTensor
(
feature
,
self
.
indices
,
self
.
spatial_shape
,
new_spt
=
SparseConvTensor
(
feature
,
self
.
indices
,
self
.
spatial_shape
,
self
.
batch_size
,
self
.
grid
,
self
.
voxel_num
,
self
.
batch_size
,
self
.
grid
,
self
.
voxel_num
,
self
.
indice_dict
)
self
.
indice_dict
)
...
...
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