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
d6078383
Commit
d6078383
authored
Jul 07, 2023
by
umangyadav
Browse files
Add evaluation for the multi-target unit-tests
parent
a01c1a5b
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
18 deletions
+38
-18
test/multi_target/multitarget_test.cpp
test/multi_target/multitarget_test.cpp
+38
-18
No files found.
test/multi_target/multitarget_test.cpp
View file @
d6078383
...
@@ -209,30 +209,50 @@ TEST_CASE(multitarget_compile_cpu_gpu)
...
@@ -209,30 +209,50 @@ TEST_CASE(multitarget_compile_cpu_gpu)
TEST_CASE
(
single_target_multi_compile
)
TEST_CASE
(
single_target_multi_compile
)
{
{
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
*
mm
=
p
.
get_main_module
();
migraphx
::
shape
boxes_s
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
4
}};
migraphx
::
shape
boxes_s
{
migraphx
::
shape
::
float_type
,
{
1
,
6
,
4
}};
auto
*
mm
=
p
.
get_main_module
();
auto
boxes_param
=
mm
->
add_parameter
(
"boxes"
,
boxes_s
);
auto
*
gpu_mod
=
p
.
create_module
(
"gpu_mod"
);
auto
boxes_param_gpu
=
gpu_mod
->
add_parameter
(
"boxes_param_gpu"
,
boxes_s
);
migraphx
::
shape
scores_s
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
6
}};
migraphx
::
shape
scores_s
{
migraphx
::
shape
::
float_type
,
{
1
,
1
,
6
}};
std
::
vector
<
float
>
scores_vec
=
{
0.9
,
0.75
,
0.6
,
0.95
,
0.5
,
0.3
};
std
::
vector
<
float
>
scores_vec
=
{
0.9
,
0.75
,
0.6
,
0.95
,
0.5
,
0.3
};
auto
scores_l
=
gpu_mod
->
add_literal
(
migraphx
::
literal
(
scores_s
,
scores_vec
));
auto
boxes_l
=
mm
->
add_parameter
(
"boxes"
,
boxes_s
);
auto
max_out_l
=
gpu_mod
->
add_literal
(
int64_t
{
4
});
auto
scores_l
=
mm
->
add_literal
(
migraphx
::
literal
(
scores_s
,
scores_vec
));
auto
iou_threshold
=
gpu_mod
->
add_literal
(
0.5
f
);
auto
max_out_l
=
mm
->
add_literal
(
int64_t
{
4
});
auto
score_threshold
=
gpu_mod
->
add_literal
(
0.0
f
);
auto
iou_threshold
=
mm
->
add_literal
(
0.5
f
);
auto
r
=
gpu_mod
->
add_instruction
(
auto
score_threshold
=
mm
->
add_literal
(
0.0
f
);
migraphx
::
make_op
(
"nonmaxsuppression"
,
{{
"center_point_box"
,
true
},
{
"use_dyn_output"
,
true
}}),
auto
r
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"nonmaxsuppression"
,
{{
"center_point_box"
,
1
}}),
boxes_param_gpu
,
boxes_l
,
scores_l
,
scores_l
,
max_out_l
,
max_out_l
,
iou_threshold
,
iou_threshold
,
score_threshold
);
score_threshold
);
mm
->
add_return
({
r
});
gpu_mod
->
add_return
({
r
});
auto
run_on_gpu
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"run_on_target"
,
{{
"target_id"
,
0
}}),
{
boxes_param
},
{
gpu_mod
});
auto
run_on_gpu_0
=
mm
->
add_instruction
(
migraphx
::
make_op
(
"get_tuple_elem"
,
{{
"index"
,
0
}}),
run_on_gpu
);
mm
->
add_return
({
run_on_gpu_0
});
// compile using multi-target compilation path
migraphx
::
compile_options
gpu_opts
;
migraphx
::
compile_options
gpu_opts
;
gpu_opts
.
offload_copy
=
true
;
gpu_opts
.
offload_copy
=
true
;
p
.
compile
({
migraphx
::
make_target
(
"gpu"
)},
{
gpu_opts
});
// need to add "ref" to avoid ambigious call to "compile()"
EXPECT
(
is_compiled_gpu_module
(
*
p
.
get_main_module
()));
p
.
compile
({
migraphx
::
make_target
(
"gpu"
),
migraphx
::
make_target
(
"ref"
)},
{
gpu_opts
});
EXPECT
(
check_compiled_program
(
p
,
{
migraphx
::
make_target
(
"gpu"
),
migraphx
::
make_target
(
"ref"
)}));
// eval
migraphx
::
parameter_map
params
;
std
::
vector
<
float
>
boxes_vec
=
{
0.5
,
0.5
,
1.0
,
1.0
,
0.5
,
0.6
,
1.0
,
1.0
,
0.5
,
0.4
,
1.0
,
1.0
,
0.5
,
10.5
,
1.0
,
1.0
,
0.5
,
10.6
,
1.0
,
1.0
,
0.5
,
100.5
,
1.0
,
1.0
};
params
[
"boxes"
]
=
migraphx
::
argument
(
boxes_s
,
boxes_vec
.
data
());
auto
output
=
p
.
eval
(
params
).
back
();
std
::
vector
<
int64_t
>
result
;
output
.
visit
([
&
](
auto
out
)
{
result
.
assign
(
out
.
begin
(),
out
.
end
());
});
std
::
vector
<
int64_t
>
gold
=
{
0
,
0
,
3
,
0
,
0
,
0
,
0
,
0
,
5
};
EXPECT
(
migraphx
::
verify_range
(
result
,
gold
));
}
}
TEST_CASE
(
multitarget_compile_if_then_else
)
TEST_CASE
(
multitarget_compile_if_then_else
)
...
...
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