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
1d3527d1
Commit
1d3527d1
authored
Sep 04, 2019
by
Shucai Xiao
Browse files
add an unit test to cover the code change
parent
9b9869c4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
57 additions
and
1 deletion
+57
-1
test/quantization.cpp
test/quantization.cpp
+57
-1
No files found.
test/quantization.cpp
View file @
1d3527d1
...
...
@@ -896,7 +896,7 @@ TEST_CASE(target_copy)
}
}
TEST_CASE
(
int8_quantization
)
TEST_CASE
(
int8_quantization
_dot
)
{
auto
run_prog
=
[](
migraphx
::
program
p
,
const
migraphx
::
target
&
t
,
...
...
@@ -958,4 +958,60 @@ TEST_CASE(int8_quantization)
}
}
TEST_CASE
(
int8_quantization_conv
)
{
auto
run_prog
=
[](
migraphx
::
program
p
,
const
migraphx
::
target
&
t
,
std
::
vector
<
float
>&
res
,
bool
b_quantize
=
false
)
{
if
(
b_quantize
)
{
std
::
vector
<
migraphx
::
program
::
parameter_map
>
cali_data
;
migraphx
::
quantize_int8
(
p
,
t
,
cali_data
);
}
p
.
compile
(
t
);
migraphx
::
program
::
parameter_map
m
;
auto
result
=
t
.
copy_from
(
p
.
eval
(
m
));
result
.
visit
([
&
](
auto
v
)
{
res
.
assign
(
v
.
begin
(),
v
.
end
());
});
};
auto
create_program
=
[]
{
migraphx
::
program
p
;
migraphx
::
shape
sx
{
migraphx
::
shape
::
float_type
,
{
4
,
2
,
2
,
2
}};
migraphx
::
shape
sw
{
migraphx
::
shape
::
float_type
,
{
4
,
2
,
2
,
2
}};
std
::
vector
<
float
>
v
(
sx
.
elements
(),
0.5
f
);
auto
input
=
p
.
add_literal
(
migraphx
::
literal
(
sx
,
v
));
auto
weights
=
p
.
add_literal
(
migraphx
::
literal
(
sw
,
v
));
p
.
add_instruction
(
migraphx
::
op
::
convolution
{},
input
,
weights
);
return
p
;
};
{
auto
p
=
create_program
();
std
::
vector
<
float
>
quant_result
;
migraphx
::
target
cpu_t
=
migraphx
::
cpu
::
target
{};
run_prog
(
p
,
cpu_t
,
quant_result
,
true
);
std
::
vector
<
float
>
no_quant_result
;
run_prog
(
p
,
cpu_t
,
no_quant_result
);
for
(
auto
v
:
no_quant_result
)
{
std
::
cout
<<
v
<<
"
\t
"
;
}
std
::
cout
<<
std
::
endl
;
for
(
auto
v
:
quant_result
)
{
std
::
cout
<<
v
<<
"
\t
"
;
}
std
::
cout
<<
std
::
endl
;
EXPECT
(
migraphx
::
verify_range
(
quant_result
,
no_quant_result
));
}
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
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