Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0598858

Browse files
committed
CPU ONLY build and minor doc changes
Squashed commit of the following: commit 26fb9f310e9a62e9775b7e6a2aabd424d0d8e521 Author: Chris Choy <[email protected]> Date: Wed Dec 25 02:12:18 2019 -0800 manifest, CPU update commit 1bc1456ccb0281486c0d08c2e5626bb4ee3047ff Author: Chris Choy <[email protected]> Date: Wed Dec 25 00:13:47 2019 -0800 CPU ONLY build commit 0f8b07253c4a24683f9dcd0d67a03e926aa20a5d Author: Chris Choy <[email protected]> Date: Tue Dec 24 23:37:03 2019 -0800 minor update on training doc commit 31766060189b49c2aeceb0584f579e8ae26afc5e Author: Chris Choy <[email protected]> Date: Tue Dec 24 13:45:48 2019 -0800 update sparse_quantize doc
1 parent 415098d commit 0598858

File tree

8 files changed

+76
-31
lines changed

8 files changed

+76
-31
lines changed

CHANGELOG.md

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,39 @@
11
# Change Log
22

33

4-
## [nightly] - 2019-12-24
4+
## [0.3.2] - 2019-12-25
55

6+
### Added
67
- Synchronized Batch Norm: `ME.MinkowskiSyncBatchNorm`
78
- `ME.MinkowskiSyncBatchNorm.convert_sync_batchnorm` converts a MinkowskiNetwork automatically to use synched batch norm.
89
- `examples/multigpu.py` update for `ME.MinkowskiSynchBatchNorm`.
10+
- Add `MinkowskiUnion`
11+
- Add CoordsManager functions
12+
- `get_batch_size`
13+
- `get_batch_indices`
14+
- `set_origin_coords_key`
15+
- Add `quantize_th`, `quantize_label_th`
16+
- Add MANIFEST
17+
18+
### Changed
19+
20+
- Update `MinkowskiUnion`, `MinkowskiPruning` docs
921
- Update multigpu documentation
1022
- Update GIL release
23+
- Use cudaMalloc instead of `at::Tensor` for GPU memory management for illegal memory access, invalid arg.
1124
- Minor error fixes on `examples/modelnet40.py`
1225
- CoordsMap size initialization updates
13-
- Add `MinkowskiUnion`
14-
- Update `MinkowskiUnion`, `MinkowskiPruning` docs
15-
- Use cudaMalloc instead of `at::Tensor` for GPU memory management for illegal memory access, invalid arg.
1626
- Region hypercube iterator with even numbered kernel
1727
- Fix global reduction in-out map with non contiguous batch indices
1828
- GlobalPooling with torch reduction
19-
- Add CoordsManager functions
20-
- `get_batch_size`
21-
- `get_batch_indices`
22-
- `set_origin_coords_key`
2329
- Update CoordsManager function `get_row_indices_per_batch` to return a list of `torch.LongTensor` for mapping indices. The corresponding batch indices is accessible by `get_batch_indices`.
2430
- Update `MinkowskiBroadcast`, `MinkowskiBroadcastConcatenation` to use row indices per batch (`getRowIndicesPerBatch`)
2531
- Update `SparseTensor`
2632
- `allow_duplicate_coords` argument support
2733
- update documentation, add unittest
28-
- Add `quantize_th`, `quantize_label_th`
2934
- Update the training demo and documentation.
3035
- Update `MinkowskiInstanceNorm`: no `dimension` argument.
36+
- Fix CPU only build
3137

3238

3339
## [0.3.1] - 2019-12-15

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Makefile
2+
recursive-include src *.hpp *.cpp *.cu *.cuh *.h
3+
recursive-include pybind *.hpp *.cpp

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# Pretty build
55
Q ?= @
66

7-
# Uncomment for CPU only build. Also uncomment the line 66 setup.py.
7+
# Uncomment for CPU only build. From the command line, `python setup.py install --cpu_only`
88
# CPU_ONLY := 1
99

1010
CXX := g++

MinkowskiEngine/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
# Please cite "4D Spatio-Temporal ConvNets: Minkowski Convolutional Neural
2222
# Networks", CVPR'19 (https://arxiv.org/abs/1904.08755) if you use any part
2323
# of the code.
24-
__version__ = "0.3.1"
24+
__version__ = "0.3.2"
2525

2626
import os
2727
import sys

MinkowskiEngine/utils/quantization.py

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,12 @@ def sparse_quantize(coords,
110110
:attr:`labels` (:attr:`numpy.ndarray` or :attr:`torch.IntTensor`,
111111
optional): integer labels associated to eah coordinates. Must have the
112112
same container as `coords` (i.e. if `coords` is a torch.Tensor,
113-
`labels` must also be a torch.Tensor).
113+
`labels` must also be a torch.Tensor). For classification where a set
114+
of points are mapped to one label, do not feed the labels.
114115
115-
:attr:`ignore_label` (:attr:`int`, optional): the int value of the IGNORE LABEL..
116+
:attr:`ignore_label` (:attr:`int`, optional): the int value of the
117+
IGNORE LABEL.
118+
:attr:`torch.nn.CrossEntropyLoss(ignore_index=ignore_label)`
116119
117120
:attr:`return_index` (:attr:`bool`, optional): True if you want the indices of the
118121
quantized coordinates. False by default.
@@ -123,11 +126,19 @@ def sparse_quantize(coords,
123126
124127
Example::
125128
129+
>>> # Segmentation
126130
>>> criterion = torch.nn.CrossEntropyLoss(ignore_index=-100)
127131
>>> coords, feats, labels = MinkowskiEngine.utils.sparse_quantize(
128132
>>> coords, feats, labels, ignore_label=-100, quantization_size=0.1)
129133
>>> output = net(MinkowskiEngine.SparseTensor(feats, coords))
130134
>>> loss = criterion(output.F, labels.long())
135+
>>>
136+
>>> # Classification
137+
>>> criterion = torch.nn.CrossEntropyLoss(ignore_index=-100)
138+
>>> coords, feats = MinkowskiEngine.utils.sparse_quantize(coords, feats)
139+
>>> output = net(MinkowskiEngine.SparseTensor(feats, coords))
140+
>>> loss = criterion(output.F, labels.long())
141+
131142
132143
"""
133144
assert isinstance(coords, np.ndarray) or isinstance(coords, torch.Tensor), \

docs/demo/training.rst

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,12 +35,16 @@ In this example, let's create a random dataset that generates a noisy line.
3535
# Drop some samples
3636
xs_data = self._sample_xs(self.num_data)
3737
ys_data = angle * xs_data + intercept + self._sample_noise(
38-
xs_data, [0, 1])
38+
self.num_data, [0, 0.1])
39+
40+
noise = 4 * (self.rng.rand(self.num_noise, 2) - 0.5)
3941
4042
# Concatenate data
41-
input = np.hstack([xs_data, ys_data])
42-
feats = np.random.rand(self.num_data, 1)
43-
labels = np.ones((self.num_data, 1)).astype(np.int32)
43+
input = np.vstack([np.hstack([xs_data, ys_data]), noise])
44+
feats = input
45+
labels = np.vstack(
46+
[np.ones((self.num_data, 1)),
47+
np.zeros((self.num_noise, 1))]).astype(np.int32)
4448
4549
...
4650

docs/quick_start.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,4 @@ room.
3838
3939
## CPU only compilation
4040
41-
1. Uncomment line 8 of the Makefile to enable the flag, `CPU_ONLY`.
42-
2. Uncomment line 57 of the `setup.py` to enable the flag, `CPU_ONLY`.
43-
3. `python setup.py install`
41+
`python setup.py install --cpu_only`

setup.py

Lines changed: 34 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,9 @@
22
import os
33
import re
44
import subprocess
5+
from sys import argv
56
from setuptools import setup
6-
from torch.utils.cpp_extension import CUDAExtension, BuildExtension
7+
from torch.utils.cpp_extension import CppExtension, CUDAExtension, BuildExtension
78

89
from distutils.sysconfig import get_python_inc
910

@@ -28,20 +29,39 @@ def run_command(*args):
2829
subprocess.call(args)
2930

3031

31-
run_command('make', 'clean')
32-
run_command('make', '-j%d' % min(os.cpu_count(), 12))
32+
# For cpu only build
33+
CPU_ONLY = '--cpu_only' in argv
34+
KEEP_OBJS = '--keep_objs' in argv
35+
36+
Extension = CUDAExtension
37+
compile_args = ['make', '-j%d' % min(os.cpu_count(), 12)]
38+
extra_compile_args = ['-Wno-deprecated-declarations']
39+
# extra_compile_args+=['-g'] # Uncomment for debugging
40+
if CPU_ONLY:
41+
argv.remove('--cpu_only')
42+
compile_args += ['CPU_ONLY=1']
43+
extra_compile_args += ['-DCPU_ONLY']
44+
Extension = CppExtension
45+
46+
if KEEP_OBJS:
47+
argv.remove('--keep_objs')
48+
49+
if not KEEP_OBJS:
50+
run_command('make', 'clean')
51+
52+
run_command(*compile_args)
3353

3454
# Python interface
3555
setup(
3656
name='MinkowskiEngine',
3757
version=find_version('MinkowskiEngine', '__init__.py'),
38-
install_requires=['torch'],
58+
install_requires=['torch', 'numpy'],
3959
packages=[
4060
'MinkowskiEngine', 'MinkowskiEngine.utils', 'MinkowskiEngine.modules'
4161
],
4262
package_dir={'MinkowskiEngine': './MinkowskiEngine'},
4363
ext_modules=[
44-
CUDAExtension(
64+
Extension(
4565
name='MinkowskiEngineBackend',
4666
include_dirs=['./', get_python_inc() + "/.."],
4767
sources=[
@@ -52,16 +72,19 @@ def run_command(*args):
5272
'openblas', # for other blas, replace openblas
5373
],
5474
library_dirs=['objs'],
55-
# extra_compile_args=['-g'] # Uncomment for debugging
56-
extra_compile_args=['-Wno-deprecated-declarations'],
57-
# extra_compile_args=['-DCPU_ONLY'] # Uncomment the following for CPU_ONLY build
75+
extra_compile_args=extra_compile_args,
5876
)
5977
],
6078
cmdclass={'build_ext': BuildExtension},
61-
author='Christopher B. Choy',
79+
author='Christopher Choy',
6280
author_email='[email protected]',
6381
description='Minkowski Engine, a Sparse Tensor Library for Neural Networks',
64-
keywords='Minkowski Engine Sparse Tensor Library Convolutional Neural Networks',
82+
long_description=read('README.md'),
83+
long_description_content_type="text/markdown",
6584
url='https://github.com/StanfordVL/MinkowskiEngine',
85+
keywords=[
86+
'pytorch', 'Minkowski Engine', 'Sparse Tensor',
87+
'Convolutional Neural Networks', '3D Vision', 'Deep Learning'
88+
],
6689
zip_safe=False,
67-
)
90+
python_requires='>=3.6')

0 commit comments

Comments
 (0)