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
vision
Commits
bae1d7e2
Unverified
Commit
bae1d7e2
authored
Nov 22, 2021
by
Joao Gomes
Committed by
GitHub
Nov 22, 2021
Browse files
Change to stable sort in nms implementations (#4767)
* change to stable sort in nms implementations
parent
7fa267e8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
3 deletions
+6
-3
torchvision/csrc/ops/cpu/nms_kernel.cpp
torchvision/csrc/ops/cpu/nms_kernel.cpp
+2
-1
torchvision/csrc/ops/cuda/nms_kernel.cu
torchvision/csrc/ops/cuda/nms_kernel.cu
+2
-1
torchvision/csrc/ops/quantized/cpu/qnms_kernel.cpp
torchvision/csrc/ops/quantized/cpu/qnms_kernel.cpp
+2
-1
No files found.
torchvision/csrc/ops/cpu/nms_kernel.cpp
View file @
bae1d7e2
...
@@ -27,7 +27,8 @@ at::Tensor nms_kernel_impl(
...
@@ -27,7 +27,8 @@ at::Tensor nms_kernel_impl(
at
::
Tensor
areas_t
=
(
x2_t
-
x1_t
)
*
(
y2_t
-
y1_t
);
at
::
Tensor
areas_t
=
(
x2_t
-
x1_t
)
*
(
y2_t
-
y1_t
);
auto
order_t
=
std
::
get
<
1
>
(
scores
.
sort
(
0
,
/* descending=*/
true
));
auto
order_t
=
std
::
get
<
1
>
(
scores
.
sort
(
/*stable=*/
true
,
/*dim=*/
0
,
/* descending=*/
true
));
auto
ndets
=
dets
.
size
(
0
);
auto
ndets
=
dets
.
size
(
0
);
at
::
Tensor
suppressed_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kByte
));
at
::
Tensor
suppressed_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kByte
));
...
...
torchvision/csrc/ops/cuda/nms_kernel.cu
View file @
bae1d7e2
...
@@ -109,7 +109,8 @@ at::Tensor nms_kernel(
...
@@ -109,7 +109,8 @@ at::Tensor nms_kernel(
return
at
::
empty
({
0
},
dets
.
options
().
dtype
(
at
::
kLong
));
return
at
::
empty
({
0
},
dets
.
options
().
dtype
(
at
::
kLong
));
}
}
auto
order_t
=
std
::
get
<
1
>
(
scores
.
sort
(
0
,
/* descending=*/
true
));
auto
order_t
=
std
::
get
<
1
>
(
scores
.
sort
(
/*stable=*/
true
,
/*dim=*/
0
,
/* descending=*/
true
));
auto
dets_sorted
=
dets
.
index_select
(
0
,
order_t
).
contiguous
();
auto
dets_sorted
=
dets
.
index_select
(
0
,
order_t
).
contiguous
();
int
dets_num
=
dets
.
size
(
0
);
int
dets_num
=
dets
.
size
(
0
);
...
...
torchvision/csrc/ops/quantized/cpu/qnms_kernel.cpp
View file @
bae1d7e2
...
@@ -27,7 +27,8 @@ at::Tensor qnms_kernel_impl(
...
@@ -27,7 +27,8 @@ at::Tensor qnms_kernel_impl(
auto
y1_t
=
dets
.
select
(
1
,
1
).
contiguous
();
auto
y1_t
=
dets
.
select
(
1
,
1
).
contiguous
();
auto
x2_t
=
dets
.
select
(
1
,
2
).
contiguous
();
auto
x2_t
=
dets
.
select
(
1
,
2
).
contiguous
();
auto
y2_t
=
dets
.
select
(
1
,
3
).
contiguous
();
auto
y2_t
=
dets
.
select
(
1
,
3
).
contiguous
();
auto
order_t
=
std
::
get
<
1
>
(
scores
.
sort
(
0
,
/* descending=*/
true
));
auto
order_t
=
std
::
get
<
1
>
(
scores
.
sort
(
/*stable=*/
true
,
/*dim=*/
0
,
/* descending=*/
true
));
at
::
Tensor
suppressed_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kByte
));
at
::
Tensor
suppressed_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kByte
));
at
::
Tensor
keep_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kLong
));
at
::
Tensor
keep_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kLong
));
at
::
Tensor
areas_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kFloat
));
at
::
Tensor
areas_t
=
at
::
zeros
({
ndets
},
dets
.
options
().
dtype
(
at
::
kFloat
));
...
...
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