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
b30a17c3
Commit
b30a17c3
authored
May 15, 2019
by
Shucai Xiao
Browse files
clang format
parent
d64ab071
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
17 deletions
+21
-17
src/include/migraphx/op/convert.hpp
src/include/migraphx/op/convert.hpp
+3
-3
src/quantization.cpp
src/quantization.cpp
+18
-14
No files found.
src/include/migraphx/op/convert.hpp
View file @
b30a17c3
...
@@ -41,7 +41,7 @@ struct convert : unary<convert>
...
@@ -41,7 +41,7 @@ struct convert : unary<convert>
}
}
convert
(
shape
::
type_t
t
)
:
target_type
{
t
}
{}
convert
(
shape
::
type_t
t
)
:
target_type
{
t
}
{}
convert
(
shape
::
type_t
t
,
float
sle
,
float
sft
)
:
target_type
{
t
},
scale
{
sle
},
shift
{
sft
}
{}
convert
(
shape
::
type_t
t
,
float
sle
,
float
sft
)
:
target_type
{
t
},
scale
{
sle
},
shift
{
sft
}
{}
convert
()
{}
convert
()
{}
};
};
...
...
src/quantization.cpp
View file @
b30a17c3
...
@@ -215,14 +215,15 @@ void quantize_int8(program& prog, const std::vector<std::string>& ins_names)
...
@@ -215,14 +215,15 @@ void quantize_int8(program& prog, const std::vector<std::string>& ins_names)
// used as scale and shift(.0f), which will generate results diffrent from
// used as scale and shift(.0f), which will generate results diffrent from
// the original results. To adjust the output to be "correct(approximatly
// the original results. To adjust the output to be "correct(approximatly
// equal)", we need additional calculation for the adjustment
// equal)", we need additional calculation for the adjustment
if
(
ins
->
name
()
==
"dot"
)
if
(
ins
->
name
()
==
"dot"
)
{
{
auto
dot_op
=
any_cast
<
op
::
dot
>
(
ins
->
get_operator
());
auto
dot_op
=
any_cast
<
op
::
dot
>
(
ins
->
get_operator
());
int32_t
quant_alpha
=
static_cast
<
int32_t
>
(
dot_op
.
alpha
/
(
int8_param
[
0
].
first
*
int8_param
[
1
].
first
)
+
0.5
f
);
int32_t
quant_alpha
=
static_cast
<
int32_t
>
(
dot_op
.
alpha
/
(
int8_param
[
0
].
first
*
int8_param
[
1
].
first
)
+
0.5
f
);
int32_t
quant_beta
=
static_cast
<
int32_t
>
(
dot_op
.
beta
+
0.5
f
);
int32_t
quant_beta
=
static_cast
<
int32_t
>
(
dot_op
.
beta
+
0.5
f
);
prog
.
replace_instruction
(
ins
,
op
::
quant_dot
{
quant_alpha
,
quant_beta
},
converted_inputs
);
prog
.
replace_instruction
(
ins
,
op
::
quant_dot
{
quant_alpha
,
quant_beta
},
converted_inputs
);
}
}
else
if
(
ins
->
name
()
==
"convolution"
)
else
if
(
ins
->
name
()
==
"convolution"
)
{
{
// Current MIOpen convolution does not support alpha and beta,
// Current MIOpen convolution does not support alpha and beta,
// so we need a separate multiply to adjust the output
// so we need a separate multiply to adjust the output
...
@@ -234,7 +235,10 @@ void quantize_int8(program& prog, const std::vector<std::string>& ins_names)
...
@@ -234,7 +235,10 @@ void quantize_int8(program& prog, const std::vector<std::string>& ins_names)
auto
group
=
conv_op
.
group
;
auto
group
=
conv_op
.
group
;
auto
adjust_factor
=
1.0
/
int8_param
[
0
].
first
*
int8_param
[
1
].
first
;
auto
adjust_factor
=
1.0
/
int8_param
[
0
].
first
*
int8_param
[
1
].
first
;
auto
conv_res
=
prog
.
insert_instruction
(
ins
,
op
::
quant_convolution
{
padding
,
stride
,
dilation
,
padding_mode
,
group
},
converted_inputs
);
auto
conv_res
=
prog
.
insert_instruction
(
ins
,
op
::
quant_convolution
{
padding
,
stride
,
dilation
,
padding_mode
,
group
},
converted_inputs
);
auto
conv_lens
=
conv_res
->
get_shape
().
lens
();
auto
conv_lens
=
conv_res
->
get_shape
().
lens
();
auto
fl
=
prog
.
add_literal
(
literal
(
adjust_factor
));
auto
fl
=
prog
.
add_literal
(
literal
(
adjust_factor
));
auto
adj_fact
=
prog
.
insert_instruction
(
ins
,
op
::
multibroadcast
{
conv_lens
},
fl
);
auto
adj_fact
=
prog
.
insert_instruction
(
ins
,
op
::
multibroadcast
{
conv_lens
},
fl
);
...
...
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