ocnn 2.2.7__py3-none-any.whl → 2.2.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- ocnn/__init__.py +24 -24
- ocnn/dataset.py +160 -160
- ocnn/models/__init__.py +29 -29
- ocnn/models/autoencoder.py +155 -155
- ocnn/models/hrnet.py +192 -192
- ocnn/models/image2shape.py +128 -128
- ocnn/models/lenet.py +46 -46
- ocnn/models/ounet.py +94 -94
- ocnn/models/resnet.py +53 -53
- ocnn/models/segnet.py +72 -72
- ocnn/models/unet.py +105 -105
- ocnn/modules/__init__.py +26 -26
- ocnn/modules/modules.py +303 -303
- ocnn/modules/resblocks.py +158 -158
- ocnn/nn/__init__.py +44 -44
- ocnn/nn/octree2col.py +53 -53
- ocnn/nn/octree2vox.py +50 -50
- ocnn/nn/octree_align.py +46 -46
- ocnn/nn/octree_conv.py +429 -429
- ocnn/nn/octree_drop.py +55 -55
- ocnn/nn/octree_dwconv.py +222 -222
- ocnn/nn/octree_gconv.py +79 -79
- ocnn/nn/octree_interp.py +196 -196
- ocnn/nn/octree_norm.py +126 -126
- ocnn/nn/octree_pad.py +39 -39
- ocnn/nn/octree_pool.py +200 -200
- ocnn/octree/__init__.py +22 -22
- ocnn/octree/octree.py +770 -661
- ocnn/octree/points.py +323 -323
- ocnn/octree/shuffled_key.py +115 -115
- ocnn/utils.py +205 -205
- {ocnn-2.2.7.dist-info → ocnn-2.2.8.dist-info}/METADATA +111 -112
- ocnn-2.2.8.dist-info/RECORD +36 -0
- {ocnn-2.2.7.dist-info → ocnn-2.2.8.dist-info}/licenses/LICENSE +21 -21
- ocnn-2.2.7.dist-info/RECORD +0 -36
- {ocnn-2.2.7.dist-info → ocnn-2.2.8.dist-info}/WHEEL +0 -0
- {ocnn-2.2.7.dist-info → ocnn-2.2.8.dist-info}/top_level.txt +0 -0
ocnn/nn/octree_align.py
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
# --------------------------------------------------------
|
|
2
|
-
# Octree-based Sparse Convolutional Neural Networks
|
|
3
|
-
# Copyright (c) 2022 Peng-Shuai Wang <wangps@hotmail.com>
|
|
4
|
-
# Licensed under The MIT License [see LICENSE for details]
|
|
5
|
-
# Written by Peng-Shuai Wang
|
|
6
|
-
# --------------------------------------------------------
|
|
7
|
-
|
|
8
|
-
import torch
|
|
9
|
-
|
|
10
|
-
from ocnn.octree import Octree
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
def search_value(value: torch.Tensor, key: torch.Tensor, query: torch.Tensor):
|
|
14
|
-
r''' Searches values according to sorted shuffled keys.
|
|
15
|
-
|
|
16
|
-
Args:
|
|
17
|
-
value (torch.Tensor): The input tensor with shape (N, C).
|
|
18
|
-
key (torch.Tensor): The key tensor corresponds to :attr:`value` with shape
|
|
19
|
-
(N,), which contains sorted shuffled keys of an octree.
|
|
20
|
-
query (torch.Tensor): The query tensor, which also contains shuffled keys.
|
|
21
|
-
'''
|
|
22
|
-
|
|
23
|
-
# deal with out-of-bound queries, the indices of these queries
|
|
24
|
-
# returned by torch.searchsorted equal to `key.shape[0]`
|
|
25
|
-
out_of_bound = query > key[-1]
|
|
26
|
-
|
|
27
|
-
# search
|
|
28
|
-
idx = torch.searchsorted(key, query)
|
|
29
|
-
idx[out_of_bound] = -1 # to avoid overflow when executing the following line
|
|
30
|
-
found = key[idx] == query
|
|
31
|
-
|
|
32
|
-
# assign the found value to the output
|
|
33
|
-
out = torch.zeros(query.shape[0], value.shape[1], device=value.device)
|
|
34
|
-
out[found] = value[idx[found]]
|
|
35
|
-
return out
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
def octree_align(value: torch.Tensor, octree: Octree, octree_query: Octree,
|
|
39
|
-
depth: int, nempty: bool = False):
|
|
40
|
-
r''' Wraps :func:`octree_align` to take octrees as input for convenience.
|
|
41
|
-
'''
|
|
42
|
-
|
|
43
|
-
key = octree.key(depth, nempty)
|
|
44
|
-
query = octree_query.key(depth, nempty)
|
|
45
|
-
assert key.shape[0] == value.shape[0]
|
|
46
|
-
return search_value(value, key, query)
|
|
1
|
+
# --------------------------------------------------------
|
|
2
|
+
# Octree-based Sparse Convolutional Neural Networks
|
|
3
|
+
# Copyright (c) 2022 Peng-Shuai Wang <wangps@hotmail.com>
|
|
4
|
+
# Licensed under The MIT License [see LICENSE for details]
|
|
5
|
+
# Written by Peng-Shuai Wang
|
|
6
|
+
# --------------------------------------------------------
|
|
7
|
+
|
|
8
|
+
import torch
|
|
9
|
+
|
|
10
|
+
from ocnn.octree import Octree
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def search_value(value: torch.Tensor, key: torch.Tensor, query: torch.Tensor):
|
|
14
|
+
r''' Searches values according to sorted shuffled keys.
|
|
15
|
+
|
|
16
|
+
Args:
|
|
17
|
+
value (torch.Tensor): The input tensor with shape (N, C).
|
|
18
|
+
key (torch.Tensor): The key tensor corresponds to :attr:`value` with shape
|
|
19
|
+
(N,), which contains sorted shuffled keys of an octree.
|
|
20
|
+
query (torch.Tensor): The query tensor, which also contains shuffled keys.
|
|
21
|
+
'''
|
|
22
|
+
|
|
23
|
+
# deal with out-of-bound queries, the indices of these queries
|
|
24
|
+
# returned by torch.searchsorted equal to `key.shape[0]`
|
|
25
|
+
out_of_bound = query > key[-1]
|
|
26
|
+
|
|
27
|
+
# search
|
|
28
|
+
idx = torch.searchsorted(key, query)
|
|
29
|
+
idx[out_of_bound] = -1 # to avoid overflow when executing the following line
|
|
30
|
+
found = key[idx] == query
|
|
31
|
+
|
|
32
|
+
# assign the found value to the output
|
|
33
|
+
out = torch.zeros(query.shape[0], value.shape[1], device=value.device)
|
|
34
|
+
out[found] = value[idx[found]]
|
|
35
|
+
return out
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
def octree_align(value: torch.Tensor, octree: Octree, octree_query: Octree,
|
|
39
|
+
depth: int, nempty: bool = False):
|
|
40
|
+
r''' Wraps :func:`octree_align` to take octrees as input for convenience.
|
|
41
|
+
'''
|
|
42
|
+
|
|
43
|
+
key = octree.key(depth, nempty)
|
|
44
|
+
query = octree_query.key(depth, nempty)
|
|
45
|
+
assert key.shape[0] == value.shape[0]
|
|
46
|
+
return search_value(value, key, query)
|