Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
039e06e4
Unverified
Commit
039e06e4
authored
Jul 07, 2020
by
tianyuandu
Committed by
GitHub
Jul 07, 2020
Browse files
use torch.cummax in corner_pool for torch 1.5+ (#390)
* synchronize from mmdetection * fix parrots
parent
b11c5660
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
mmcv/ops/corner_pool.py
mmcv/ops/corner_pool.py
+19
-1
No files found.
mmcv/ops/corner_pool.py
View file @
039e06e4
import
torch
from
torch
import
nn
from
torch
import
nn
from
torch.autograd
import
Function
from
torch.autograd
import
Function
...
@@ -98,10 +99,27 @@ class CornerPool(nn.Module):
...
@@ -98,10 +99,27 @@ class CornerPool(nn.Module):
'top'
:
TopPoolFunction
,
'top'
:
TopPoolFunction
,
}
}
cummax_dim_flip
=
{
'bottom'
:
(
2
,
False
),
'left'
:
(
3
,
True
),
'right'
:
(
3
,
False
),
'top'
:
(
2
,
True
),
}
def
__init__
(
self
,
mode
):
def
__init__
(
self
,
mode
):
super
(
CornerPool
,
self
).
__init__
()
super
(
CornerPool
,
self
).
__init__
()
assert
mode
in
self
.
pool_functions
assert
mode
in
self
.
pool_functions
self
.
mode
=
mode
self
.
corner_pool
=
self
.
pool_functions
[
mode
]
self
.
corner_pool
=
self
.
pool_functions
[
mode
]
def
forward
(
self
,
x
):
def
forward
(
self
,
x
):
return
self
.
corner_pool
.
apply
(
x
)
if
torch
.
__version__
!=
'parrots'
and
torch
.
__version__
>=
'1.5.0'
:
dim
,
flip
=
self
.
cummax_dim_flip
[
self
.
mode
]
if
flip
:
x
=
x
.
flip
(
dim
)
pool_tensor
,
_
=
torch
.
cummax
(
x
,
dim
=
dim
)
if
flip
:
pool_tensor
=
pool_tensor
.
flip
(
dim
)
return
pool_tensor
else
:
return
self
.
corner_pool
.
apply
(
x
)
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