Commit 5759db44 authored by yan.yan's avatar yan.yan
Browse files

small changes, publish v2.1.8 prebuilts

parent 1a333c99
......@@ -34,7 +34,7 @@
[![Build Status](https://github.com/traveller59/spconv/workflows/build/badge.svg)](https://github.com/traveller59/spconv/actions?query=workflow%3Abuild)
| | PyPi | Install |Downloads |
| | PyPI | 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] |
| 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
## 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.
## Usage
......
......@@ -21,6 +21,7 @@ import torch
def main():
np.random.seed(50051)
# voxel gen source code: spconv/csrc/sparse/pointops.py
gen = Point2VoxelCPU3d(vsize_xyz=[0.1, 0.1, 0.1],
coors_range_xyz=[-80, -80, -2, 80, 80, 6],
......@@ -36,7 +37,7 @@ def main():
voxels_np = voxels_tv.numpy_view()
indices_np = indices_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])
# 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(
......@@ -49,6 +50,7 @@ def main():
def main_point_with_features():
np.random.seed(50051)
# voxel gen source code: spconv/csrc/sparse/pointops.py
gen = Point2VoxelCPU3d(
vsize_xyz=[0.1, 0.1, 0.1],
......@@ -68,7 +70,7 @@ def main_point_with_features():
voxels_np = voxels_tv.numpy_view()
indices_np = indices_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])
# 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(
......@@ -81,6 +83,7 @@ def main_point_with_features():
def main_pytorch_voxel_gen():
np.random.seed(50051)
# voxel gen source code: spconv/csrc/sparse/pointops.py
gen = PointToVoxel(vsize_xyz=[0.1, 0.1, 0.1],
coors_range_xyz=[-80, -80, -2, 80, 80, 6],
......@@ -94,7 +97,7 @@ def main_pytorch_voxel_gen():
voxels_np = voxels_th.numpy()
indices_np = indices_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])
# 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)
......@@ -106,6 +109,7 @@ def main_pytorch_voxel_gen():
def main_pytorch_voxel_gen_cuda():
np.random.seed(50051)
# voxel gen source code: spconv/csrc/sparse/pointops.py
device = torch.device("cuda:0")
gen = PointToVoxel(vsize_xyz=[0.1, 0.1, 0.1],
......@@ -121,7 +125,7 @@ def main_pytorch_voxel_gen_cuda():
voxels_np = voxels_th.cpu().numpy()
indices_np = indices_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])
# 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)
......
......@@ -3,17 +3,21 @@ from pathlib import Path
import numpy as np
import torch
from spconv.pytorch import ops, functional
from spconv.pytorch.conv import (SparseConv2d, SparseConv3d,
from spconv.pytorch import functional, ops
from spconv.pytorch.conv import (SparseConv1d, SparseConv2d, SparseConv3d,
SparseConv4d, SparseConvTranspose1d,
SparseConvTranspose2d, SparseConvTranspose3d,
SparseConvTranspose4d, SparseInverseConv1d,
SparseInverseConv2d, SparseInverseConv3d,
SubMConv2d, SubMConv3d)
SparseInverseConv4d, SubMConv1d, SubMConv2d,
SubMConv3d, SubMConv4d)
from spconv.pytorch.core import SparseConvTensor
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.pool import SparseMaxPool2d, SparseMaxPool3d
from spconv.pytorch.pool import (SparseMaxPool1d, SparseMaxPool2d,
SparseMaxPool3d, SparseMaxPool4d)
from spconv.pytorch.tables import AddTable, ConcatTable, JoinTable
......
......@@ -140,10 +140,11 @@ class SparseConvTensor(metaclass=SpConvTensorMeta):
self.thrust_allocator = ThrustSortAllocator(features.device)
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))
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,
self.batch_size, self.grid, self.voxel_num,
self.indice_dict)
......
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