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
1ea1b489
Unverified
Commit
1ea1b489
authored
Nov 22, 2022
by
q.yao
Committed by
GitHub
Nov 22, 2022
Browse files
[Fix] Fix roi align symbolic for torch>=1.13 (#2443)
* fix roi align symbolic for torch>1.13 * fix lint
parent
5f58b910
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
mmcv/ops/roi_align.py
mmcv/ops/roi_align.py
+14
-5
No files found.
mmcv/ops/roi_align.py
View file @
1ea1b489
...
@@ -20,16 +20,25 @@ class RoIAlignFunction(Function):
...
@@ -20,16 +20,25 @@ class RoIAlignFunction(Function):
def
symbolic
(
g
,
input
,
rois
,
output_size
,
spatial_scale
,
sampling_ratio
,
def
symbolic
(
g
,
input
,
rois
,
output_size
,
spatial_scale
,
sampling_ratio
,
pool_mode
,
aligned
):
pool_mode
,
aligned
):
from
torch.onnx
import
TensorProtoDataType
from
torch.onnx
import
TensorProtoDataType
from
torch.onnx.symbolic_helper
import
_slice_helper
from
torch.onnx.symbolic_opset9
import
sub
from
torch.onnx.symbolic_opset9
import
squeeze
,
sub
def
_select
(
g
,
self
,
dim
,
index
):
return
g
.
op
(
'Gather'
,
self
,
index
,
axis_i
=
dim
)
# batch_indices = rois[:, 0].long()
# batch_indices = rois[:, 0].long()
batch_indices
=
_slice_helper
(
g
,
rois
,
axes
=
[
1
],
starts
=
[
0
],
ends
=
[
1
])
batch_indices
=
_select
(
batch_indices
=
squeeze
(
g
,
batch_indices
,
1
)
g
,
rois
,
1
,
g
.
op
(
'Constant'
,
value_t
=
torch
.
tensor
([
0
],
dtype
=
torch
.
long
)))
batch_indices
=
g
.
op
(
'Squeeze'
,
batch_indices
,
axes_i
=
[
1
])
batch_indices
=
g
.
op
(
batch_indices
=
g
.
op
(
'Cast'
,
batch_indices
,
to_i
=
TensorProtoDataType
.
INT64
)
'Cast'
,
batch_indices
,
to_i
=
TensorProtoDataType
.
INT64
)
# rois = rois[:, 1:]
# rois = rois[:, 1:]
rois
=
_slice_helper
(
g
,
rois
,
axes
=
[
1
],
starts
=
[
1
],
ends
=
[
5
])
rois
=
_select
(
g
,
rois
,
1
,
g
.
op
(
'Constant'
,
value_t
=
torch
.
tensor
([
1
,
2
,
3
,
4
],
dtype
=
torch
.
long
)))
if
aligned
:
if
aligned
:
# rois -= 0.5/spatial_scale
# rois -= 0.5/spatial_scale
aligned_offset
=
g
.
op
(
aligned_offset
=
g
.
op
(
...
...
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