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
gaoqiong
MIGraphX
Commits
33227d1f
Unverified
Commit
33227d1f
authored
Mar 09, 2023
by
Ted Themistokleous
Committed by
GitHub
Mar 09, 2023
Browse files
Merge branch 'develop' into update_onnxrt_sync_github_action
parents
72e2a70f
69799cb8
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
32 deletions
+38
-32
src/CMakeLists.txt
src/CMakeLists.txt
+4
-1
src/eliminate_data_type.cpp
src/eliminate_data_type.cpp
+1
-0
src/include/migraphx/op/nonmaxsuppression.hpp
src/include/migraphx/op/nonmaxsuppression.hpp
+33
-31
No files found.
src/CMakeLists.txt
View file @
33227d1f
...
...
@@ -251,7 +251,10 @@ find_package(PkgConfig)
pkg_check_modules
(
SQLITE3 REQUIRED IMPORTED_TARGET sqlite3
)
target_link_libraries
(
migraphx PRIVATE PkgConfig::SQLITE3
)
find_package
(
msgpack REQUIRED
)
find_package
(
msgpackc-cxx
)
if
(
NOT msgpackc-cxx_FOUND
)
find_package
(
msgpack REQUIRED
)
endif
()
target_link_libraries
(
migraphx PRIVATE msgpackc-cxx
)
# Make this available to the tests
target_link_libraries
(
migraphx INTERFACE $<BUILD_INTERFACE:msgpackc-cxx>
)
...
...
src/eliminate_data_type.cpp
View file @
33227d1f
...
...
@@ -38,6 +38,7 @@ void eliminate_data_type::apply(module& m) const
"if"
,
"loop"
,
"roialign"
,
"nonmaxsuppression"
,
"scatternd_add"
,
"scatternd_mul"
,
"scatternd_none"
};
...
...
src/include/migraphx/op/nonmaxsuppression.hpp
View file @
33227d1f
...
...
@@ -143,16 +143,22 @@ struct nonmaxsuppression
void
sort
()
{
std
::
sort
(
x
.
begin
(),
x
.
end
());
std
::
sort
(
y
.
begin
(),
y
.
end
());
if
(
x
[
0
]
>
x
[
1
])
{
std
::
swap
(
x
[
0
],
x
[
1
]);
}
if
(
y
[
0
]
>
y
[
1
])
{
std
::
swap
(
y
[
0
],
y
[
1
]);
}
}
std
::
array
<
double
,
2
>&
operator
[](
std
::
size_t
i
)
{
return
i
==
0
?
x
:
y
;
}
double
area
()
const
{
assert
(
std
::
is_sorted
(
x
.
begin
(),
x
.
end
())
);
assert
(
std
::
is_sorted
(
y
.
begin
(),
y
.
end
())
);
assert
(
x
[
0
]
<=
x
[
1
]
);
assert
(
y
[
0
]
<=
y
[
1
]
);
return
(
x
[
1
]
-
x
[
0
])
*
(
y
[
1
]
-
y
[
0
]);
}
};
...
...
@@ -190,15 +196,11 @@ struct nonmaxsuppression
{
intersection
[
i
][
0
]
=
std
::
max
(
b1
[
i
][
0
],
b2
[
i
][
0
]);
intersection
[
i
][
1
]
=
std
::
min
(
b1
[
i
][
1
],
b2
[
i
][
1
]);
}
std
::
vector
<
std
::
array
<
double
,
2
>>
bbox
=
{
intersection
.
x
,
intersection
.
y
};
if
(
std
::
any_of
(
bbox
.
begin
(),
bbox
.
end
(),
[](
auto
bx
)
{
return
not
std
::
is_sorted
(
bx
.
begin
(),
bx
.
end
());
}))
if
(
intersection
[
i
][
0
]
>
intersection
[
i
][
1
])
{
return
false
;
}
}
const
double
area1
=
b1
.
area
();
const
double
area2
=
b2
.
area
();
...
...
@@ -265,32 +267,32 @@ struct nonmaxsuppression
auto
batch_boxes_start
=
boxes
.
begin
()
+
batch_idx
*
num_boxes
*
4
;
auto
boxes_heap
=
filter_boxes_by_score
(
scores_start
,
num_boxes
,
score_threshold
);
selected_boxes_inside_class
.
clear
();
// Get the next box with top score, filter by iou_threshold
while
(
not
boxes_heap
.
empty
()
&&
selected_boxes_inside_class
.
size
()
<
max_output_boxes_per_class
)
{
//
Check with existing selected boxes for this class, remove box if it
//
exceeds the IOU (Intersection Over Union) threshold
//
select next top scorer box and remove any boxes from boxes_heap that exceeds IOU
//
threshold with the selected box
const
auto
next_top_score
=
boxes_heap
.
top
();
bool
not_selected
=
std
::
any_of
(
selected_boxes_inside_class
.
begin
(),
selected_boxes_inside_class
.
end
(),
[
&
](
auto
selected_index
)
{
return
this
->
suppress_by_iou
(
batch_box
(
batch_boxes_start
,
next_top_score
.
second
),
batch_box
(
batch_boxes_start
,
selected_index
.
second
),
iou_threshold
);
});
if
(
not
not_selected
)
{
boxes_heap
.
pop
();
selected_boxes_inside_class
.
push_back
(
next_top_score
);
selected_indices
.
push_back
(
batch_idx
);
selected_indices
.
push_back
(
class_idx
);
selected_indices
.
push_back
(
next_top_score
.
second
);
std
::
priority_queue
<
std
::
pair
<
double
,
int64_t
>>
remainder_boxes
;
while
(
not
boxes_heap
.
empty
())
{
auto
iou_candidate_box
=
boxes_heap
.
top
();
if
(
not
this
->
suppress_by_iou
(
batch_box
(
batch_boxes_start
,
iou_candidate_box
.
second
),
batch_box
(
batch_boxes_start
,
next_top_score
.
second
),
iou_threshold
))
{
remainder_boxes
.
push
(
iou_candidate_box
);
}
boxes_heap
.
pop
();
}
boxes_heap
=
remainder_boxes
;
}
});
std
::
copy
(
selected_indices
.
begin
(),
selected_indices
.
end
(),
output
.
begin
());
return
selected_indices
.
size
()
/
3
;
...
...
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