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
51bd00b3
Commit
51bd00b3
authored
Sep 05, 2019
by
Paul
Browse files
Merge branch 'develop' into so-version
parents
a79beae7
b4f11615
Pipeline
#673
failed with stages
in 0 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
9 deletions
+51
-9
src/quantization.cpp
src/quantization.cpp
+7
-8
test/quantization.cpp
test/quantization.cpp
+44
-1
No files found.
src/quantization.cpp
View file @
51bd00b3
...
...
@@ -258,14 +258,13 @@ static void ins_quantize_int8(program& prog,
{
// Current MIOpen convolution does not support alpha and beta,
// so we need a separate multiply to adjust the output
auto
conv_op
=
any_cast
<
op
::
convolution
>
(
ins
->
get_operator
());
auto
padding
=
conv_op
.
padding
;
auto
stride
=
conv_op
.
stride
;
auto
dilation
=
conv_op
.
dilation
;
auto
padding_mode
=
conv_op
.
padding_mode
;
auto
group
=
conv_op
.
group
;
auto
adjust_factor
=
std
::
round
(
1.0
f
/
(
ins_quant_params
[
0
].
first
*
ins_quant_params
[
1
].
first
));
auto
conv_op
=
any_cast
<
op
::
convolution
>
(
ins
->
get_operator
());
auto
padding
=
conv_op
.
padding
;
auto
stride
=
conv_op
.
stride
;
auto
dilation
=
conv_op
.
dilation
;
auto
padding_mode
=
conv_op
.
padding_mode
;
auto
group
=
conv_op
.
group
;
auto
adjust_factor
=
1.0
f
/
(
ins_quant_params
[
0
].
first
*
ins_quant_params
[
1
].
first
);
auto
quant_conv
=
prog
.
insert_instruction
(
ins
,
...
...
test/quantization.cpp
View file @
51bd00b3
...
...
@@ -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,47 @@ 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
);
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