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
73ae15f5
Commit
73ae15f5
authored
Oct 23, 2023
by
Brian Pickrell
Browse files
Added a test to upsample, also two ONNX test files. Tests pass.
parent
9a1a92f5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
67 additions
and
4 deletions
+67
-4
test/onnx/gen_onnx.py
test/onnx/gen_onnx.py
+22
-1
test/onnx/resize_downsample_f_dyn_test.onnx
test/onnx/resize_downsample_f_dyn_test.onnx
+0
-0
test/onnx/resize_upsample_f_dyn_test.onnx
test/onnx/resize_upsample_f_dyn_test.onnx
+0
-0
test/onnx/verify_onnx.cpp
test/onnx/verify_onnx.cpp
+45
-3
No files found.
test/onnx/gen_onnx.py
View file @
73ae15f5
...
@@ -5666,7 +5666,6 @@ def resize_downsample_f_test():
...
@@ -5666,7 +5666,6 @@ def resize_downsample_f_test():
return
([
node
],
[
X
],
[
Y
],
[
scale_tensor
])
return
([
node
],
[
X
],
[
Y
],
[
scale_tensor
])
@
onnx_test
()
@
onnx_test
()
def
resize_downsample_f_dyn_test
():
def
resize_downsample_f_dyn_test
():
scales
=
np
.
array
([
1.0
,
1.0
,
0.601
,
0.601
],
dtype
=
np
.
float32
)
scales
=
np
.
array
([
1.0
,
1.0
,
0.601
,
0.601
],
dtype
=
np
.
float32
)
...
@@ -5689,6 +5688,28 @@ def resize_downsample_f_dyn_test():
...
@@ -5689,6 +5688,28 @@ def resize_downsample_f_dyn_test():
return
([
node
],
[
X
],
[
Y
],
[
scale_tensor
])
return
([
node
],
[
X
],
[
Y
],
[
scale_tensor
])
@
onnx_test
()
def
resize_upsample_f_dyn_test
():
scales
=
np
.
array
([
1.0
,
1.0
,
1.601
,
1.601
],
dtype
=
np
.
float32
)
scale_tensor
=
helper
.
make_tensor
(
name
=
'scales'
,
data_type
=
TensorProto
.
FLOAT
,
dims
=
scales
.
shape
,
vals
=
scales
.
flatten
().
astype
(
np
.
float32
))
X
=
helper
.
make_tensor_value_info
(
'X'
,
TensorProto
.
FLOAT
,
[
None
,
1
,
3
,
5
])
Y
=
helper
.
make_tensor_value_info
(
'Y'
,
TensorProto
.
FLOAT
,
[])
node
=
onnx
.
helper
.
make_node
(
'Resize'
,
inputs
=
[
'X'
,
''
,
'scales'
],
outputs
=
[
'Y'
],
coordinate_transformation_mode
=
'half_pixel'
,
mode
=
'nearest'
,
nearest_mode
=
'round_prefer_ceil'
)
return
([
node
],
[
X
],
[
Y
],
[
scale_tensor
])
@
onnx_test
()
@
onnx_test
()
def
resize_downsample_c_test
():
def
resize_downsample_c_test
():
scales
=
np
.
array
([
1.0
,
1.0
,
0.6
,
0.6
],
dtype
=
np
.
float32
)
scales
=
np
.
array
([
1.0
,
1.0
,
0.6
,
0.6
],
dtype
=
np
.
float32
)
...
...
test/onnx/resize_downsample_f_dyn_test.onnx
0 → 100644
View file @
73ae15f5
File added
test/onnx/resize_upsample_f_dyn_test.onnx
0 → 100644
View file @
73ae15f5
File added
test/onnx/verify_onnx.cpp
View file @
73ae15f5
...
@@ -1266,7 +1266,6 @@ TEST_CASE(resize_downsample_f_test)
...
@@ -1266,7 +1266,6 @@ TEST_CASE(resize_downsample_f_test)
EXPECT
(
migraphx
::
verify
::
verify_range
(
result_vector
,
gold
));
EXPECT
(
migraphx
::
verify
::
verify_range
(
result_vector
,
gold
));
}
}
TEST_CASE
(
resize_downsample_f_dyn_test
)
TEST_CASE
(
resize_downsample_f_dyn_test
)
{
{
migraphx
::
onnx_options
options
;
migraphx
::
onnx_options
options
;
...
@@ -1274,7 +1273,6 @@ TEST_CASE(resize_downsample_f_dyn_test)
...
@@ -1274,7 +1273,6 @@ TEST_CASE(resize_downsample_f_dyn_test)
options
.
use_dyn_output
=
true
;
options
.
use_dyn_output
=
true
;
auto
p
=
migraphx
::
parse_onnx
(
"resize_downsample_f_dyn_test.onnx"
,
options
);
auto
p
=
migraphx
::
parse_onnx
(
"resize_downsample_f_dyn_test.onnx"
,
options
);
// migraphx::program p = migraphx::parse_onnx("resize_downsample_f_dyn_test.onnx");
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
5
,
9
}};
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
5
,
9
}};
...
@@ -1290,7 +1288,51 @@ p.debug_print();
...
@@ -1290,7 +1288,51 @@ p.debug_print();
printf
(
"result_vector has size %lu:
\n
"
,
result_vector
.
size
());
printf
(
"result_vector has size %lu:
\n
"
,
result_vector
.
size
());
for
(
float
aa
:
result_vector
)
printf
(
" %f "
,
aa
);
printf
(
"
\n
"
);
for
(
float
aa
:
result_vector
)
printf
(
" %f "
,
aa
);
printf
(
"
\n
"
);
std
::
vector
<
float
>
gold
=
{
0.0
f
,
3.0
f
};
// clang-format off
// TODO: gold value includes floating-point rounding errors
std
::
vector
<
float
>
gold
=
{
0.100000
,
1.100000
,
3.100000
,
4.100000
,
6.100000
,
9.100000
,
10.100000
,
12.100000
,
13.100000
,
15.100000
,
27.100000
,
28.100000
,
30.100000
,
31.100000
,
33.099998
,
45.099998
,
46.099998
,
48.099998
,
49.099998
,
51.099998
,
54.099998
,
55.099998
,
57.099998
,
58.099998
,
60.099998
,
72.099998
,
73.099998
,
75.099998
,
76.099998
,
78.099998
};
// clang-format on
EXPECT
(
migraphx
::
verify
::
verify_range
(
result_vector
,
gold
));
}
TEST_CASE
(
resize_upsample_f_dyn_test
)
{
// resize with half_pixel and round_prefer_ceil, with scale > 1
migraphx
::
onnx_options
options
;
options
.
default_dyn_dim_value
=
{
1
,
10
};
options
.
use_dyn_output
=
true
;
auto
p
=
migraphx
::
parse_onnx
(
"resize_upsample_f_dyn_test.onnx"
,
options
);
p
.
compile
(
migraphx
::
make_target
(
"ref"
));
// should upscale to 2x4x8
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
2
,
1
,
3
,
5
}};
std
::
vector
<
float
>
dx
(
sx
.
elements
());
std
::
iota
(
dx
.
begin
(),
dx
.
end
(),
0.1
f
);
migraphx
::
parameter_map
pp
;
pp
[
"X"
]
=
migraphx
::
argument
(
sx
,
dx
.
data
());
auto
result
=
p
.
eval
(
pp
).
back
();
std
::
vector
<
float
>
result_vector
;
result
.
visit
([
&
](
auto
output
)
{
result_vector
.
assign
(
output
.
begin
(),
output
.
end
());
});
// clang-format off
std
::
vector
<
float
>
gold
=
{
0.1
f
,
0.1
f
,
1.1
f
,
2.1
f
,
2.1
f
,
3.1
f
,
4.1
f
,
4.1
f
,
0.1
f
,
0.1
f
,
1.1
f
,
2.1
f
,
2.1
f
,
3.1
f
,
4.1
f
,
4.1
f
,
5.1
f
,
5.1
f
,
6.1
f
,
7.1
f
,
7.1
f
,
8.1
f
,
9.1
f
,
9.1
f
,
10.1
f
,
10.1
f
,
11.1
f
,
12.1
f
,
12.1
f
,
13.1
f
,
14.1
f
,
14.1
f
,
15.1
f
,
15.1
f
,
16.1
f
,
17.1
f
,
17.1
f
,
18.1
f
,
19.1
f
,
19.1
f
,
15.1
f
,
15.1
f
,
16.1
f
,
17.1
f
,
17.1
f
,
18.1
f
,
19.1
f
,
19.1
f
,
20.1
f
,
20.1
f
,
21.1
f
,
22.1
f
,
22.1
f
,
23.1
f
,
24.1
f
,
24.1
f
,
25.1
f
,
25.1
f
,
26.1
f
,
27.1
f
,
27.1
f
,
28.1
f
,
29.1
f
,
29.1
f
};
// clang-format on
EXPECT
(
migraphx
::
verify
::
verify_range
(
result_vector
,
gold
));
EXPECT
(
migraphx
::
verify
::
verify_range
(
result_vector
,
gold
));
}
}
...
...
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