-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Dusan Malic
committed
Jan 29, 2021
1 parent
f79df70
commit 091612a
Showing
2 changed files
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
from .conv import * | ||
from .pooling import * | ||
from .detection import * | ||
from .layernorm import * |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from torch import nn | ||
|
||
from torchsparse.sparse_tensor import * | ||
|
||
__all__ = ['LayerNorm'] | ||
|
||
|
||
class LayerNorm(nn.LayerNorm): | ||
def __init__(self, | ||
normalized_shape, | ||
eps=1e-05, | ||
elementwise_affine=True): | ||
super().__init__(normalized_shape, eps=eps, elementwise_affine=elementwise_affine) | ||
|
||
def forward(self, inputs): | ||
features = inputs.F | ||
coords = inputs.C | ||
cur_stride = inputs.s | ||
output_features = super().forward(features) | ||
output_tensor = SparseTensor(output_features, coords, cur_stride) | ||
output_tensor.coord_maps = inputs.coord_maps | ||
output_tensor.kernel_maps = inputs.kernel_maps | ||
return output_tensor |