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
14b8b661
Commit
14b8b661
authored
Apr 25, 2020
by
benzlxs
Browse files
add ConcaTable, JoinTable, Identity functions
parent
16491dc0
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
6 deletions
+67
-6
spconv/__init__.py
spconv/__init__.py
+8
-6
spconv/identity.py
spconv/identity.py
+15
-0
spconv/tables.py
spconv/tables.py
+44
-0
No files found.
spconv/__init__.py
View file @
14b8b661
...
@@ -23,6 +23,8 @@ from spconv.conv import SparseConvTranspose2d, SparseConvTranspose3d
...
@@ -23,6 +23,8 @@ from spconv.conv import SparseConvTranspose2d, SparseConvTranspose3d
from
spconv.conv
import
SparseInverseConv2d
,
SparseInverseConv3d
from
spconv.conv
import
SparseInverseConv2d
,
SparseInverseConv3d
from
spconv.modules
import
SparseModule
,
SparseSequential
from
spconv.modules
import
SparseModule
,
SparseSequential
from
spconv.pool
import
SparseMaxPool2d
,
SparseMaxPool3d
from
spconv.pool
import
SparseMaxPool2d
,
SparseMaxPool3d
from
spconv.tables
import
ConcatTable
,
JoinTable
from
spconv.identity
import
Identity
from
spconv
import
ops
from
spconv
import
ops
...
...
spconv/identity.py
0 → 100644
View file @
14b8b661
# Copyright 2016-present, Facebook, Inc.
# All rights reserved.
#
# This source code is licensed under the license found in the
# LICENSE file in the root directory of this source tree.
from
torch.nn
import
Module
class
Identity
(
Module
):
def
forward
(
self
,
input
):
return
input
def
input_spatial_size
(
self
,
out_size
):
return
out_size
spconv/tables.py
0 → 100644
View file @
14b8b661
from
torch.autograd
import
Function
#from torch.nn import Module
from
spconv.modules
import
SparseModule
import
spconv
import
torch
class
JoinTable
(
SparseModule
):
# Module):
def
forward
(
self
,
input
):
output
=
spconv
.
SparseConvTensor
(
torch
.
cat
([
i
.
features
for
i
in
input
],
1
),
input
[
1
].
indices
,
input
[
1
].
spatial_shape
,
input
[
0
].
batch_size
)
output
.
indice_dict
=
input
[
1
].
indice_dict
output
.
grid
=
input
[
1
].
grid
return
output
def
input_spatial_size
(
self
,
out_size
):
return
out_size
class
AddTable
(
SparseModule
):
# Module):
def
forward
(
self
,
input
):
output
=
spconv
.
SparseConvTensor
(
sum
([
i
.
features
for
i
in
input
]),
input
[
1
].
indices
,
input
[
1
].
spatial_shape
,
input
[
1
].
batch_size
)
output
.
indice_dict
=
input
[
1
].
indice_dict
output
.
grid
=
input
[
1
].
grid
return
output
def
input_spatial_size
(
self
,
out_size
):
return
out_size
class
ConcatTable
(
SparseModule
):
# Module):
def
forward
(
self
,
input
):
return
[
module
(
input
)
for
module
in
self
.
_modules
.
values
()]
def
add
(
self
,
module
):
self
.
_modules
[
str
(
len
(
self
.
_modules
))]
=
module
return
self
def
input_spatial_size
(
self
,
out_size
):
return
self
.
_modules
[
'0'
].
input_spatial_size
(
out_size
)
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