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
43d39b4e
Commit
43d39b4e
authored
Jun 05, 2019
by
Shucai Xiao
Browse files
clang format
parent
ffa6a45a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
7 deletions
+11
-7
src/quantization.cpp
src/quantization.cpp
+9
-6
src/targets/cpu/lowering.cpp
src/targets/cpu/lowering.cpp
+2
-1
No files found.
src/quantization.cpp
View file @
43d39b4e
...
...
@@ -278,21 +278,24 @@ void quantize_int8(program& prog,
prog
.
replace_instruction
(
ins
,
op
::
convert
{
orig_type
},
quant_dot
);
}
}
// either alpha or beta cannot be quantized because of too big
// either alpha or beta cannot be quantized because of too big
// relative rounding error
else
{
auto
q_dot
=
prog
.
insert_instruction
(
ins
,
op
::
quant_dot
{
1
,
0
},
converted_inputs
);
if
(
inputs
.
size
()
==
3
and
dot_op
.
beta
!=
0.0
f
)
if
(
inputs
.
size
()
==
3
and
dot_op
.
beta
!=
0.0
f
)
{
auto
alpha_ab
=
prog
.
insert_instruction
(
ins
,
op
::
convert
{
orig_type
,
new_alpha
,
0.0
f
},
q_dot
);
auto
alpha_ab
=
prog
.
insert_instruction
(
ins
,
op
::
convert
{
orig_type
,
new_alpha
,
0.0
f
},
q_dot
);
auto
c_shape
=
q_dot
->
get_shape
();
std
::
vector
<
float
>
vec_beta
(
c_shape
.
elements
(),
dot_op
.
beta
);
auto
l_beta
=
prog
.
add_literal
(
literal
({
shape
::
float_type
,
c_shape
.
lens
()},
vec_beta
));
auto
l_beta
=
prog
.
add_literal
(
literal
({
shape
::
float_type
,
c_shape
.
lens
()},
vec_beta
));
instruction_ref
beta_c
{};
if
(
orig_type
!=
shape
::
float_type
)
if
(
orig_type
!=
shape
::
float_type
)
{
auto
fp32_c
=
prog
.
insert_instruction
(
ins
,
op
::
convert
{
shape
::
float_type
},
inputs
.
back
());
auto
fp32_c
=
prog
.
insert_instruction
(
ins
,
op
::
convert
{
shape
::
float_type
},
inputs
.
back
());
auto
fp32_beta_c
=
prog
.
insert_instruction
(
ins
,
op
::
mul
{},
l_beta
,
fp32_c
);
beta_c
=
prog
.
insert_instruction
(
ins
,
op
::
convert
{
orig_type
},
fp32_beta_c
);
}
...
...
src/targets/cpu/lowering.cpp
View file @
43d39b4e
...
...
@@ -249,7 +249,8 @@ struct cpu_quant_convolution
const
auto
in_ch
=
group_id
*
wei_c
+
k
;
if
(
in_x
>=
0
&&
in_x
<
in_h
&&
in_y
>=
0
&&
in_y
<
in_w
)
{
acc
+=
static_cast
<
int32_t
>
(
input
(
o
,
in_ch
,
in_x
,
in_y
))
*
weights
(
w
,
k
,
x
,
y
);
acc
+=
static_cast
<
int32_t
>
(
input
(
o
,
in_ch
,
in_x
,
in_y
))
*
weights
(
w
,
k
,
x
,
y
);
}
});
output
(
o
,
w
,
i
,
j
)
=
acc
;
...
...
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