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
4ce41ebc
Commit
4ce41ebc
authored
Aug 29, 2019
by
Shucai Xiao
Browse files
clang format
parent
33ce5786
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
10 deletions
+13
-10
src/quantization.cpp
src/quantization.cpp
+3
-3
test/gpu/quantization.cpp
test/gpu/quantization.cpp
+10
-7
No files found.
src/quantization.cpp
View file @
4ce41ebc
...
...
@@ -163,9 +163,9 @@ void quantize(program& prog, const std::vector<std::string>& ins_names)
void
quantize
(
program
&
prog
)
{
quantize
(
prog
,
{
"all"
});
}
static
void
ins_quantize_int8
(
program
&
prog
,
instruction_ref
ins
,
std
::
vector
<
instruction_ref
>&
converted_inputs
,
const
std
::
vector
<
std
::
pair
<
float
,
float
>>&
ins_quant_params
)
instruction_ref
ins
,
std
::
vector
<
instruction_ref
>&
converted_inputs
,
const
std
::
vector
<
std
::
pair
<
float
,
float
>>&
ins_quant_params
)
{
auto
orig_type
=
ins
->
get_shape
().
type
();
auto
inputs
=
ins
->
inputs
();
...
...
test/gpu/quantization.cpp
View file @
4ce41ebc
...
...
@@ -96,10 +96,10 @@ TEST_CASE(dot_large_alpha_beta_float)
// add the shift
std
::
vector
<
float
>
vsa
(
sa
.
elements
(),
1.0
f
);
auto
sfta
=
p
.
add_literal
(
migraphx
::
literal
(
sa
,
vsa
));
auto
msa
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sfta
,
ma
);
auto
ra
=
p
.
add_instruction
(
migraphx
::
op
::
round
{},
msa
);
auto
ca
=
p
.
add_instruction
(
migraphx
::
op
::
clip
{
127.0
f
,
-
128.0
f
},
ra
);
auto
qa
=
p
.
add_instruction
(
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int8_type
},
ca
);
auto
msa
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sfta
,
ma
);
auto
ra
=
p
.
add_instruction
(
migraphx
::
op
::
round
{},
msa
);
auto
ca
=
p
.
add_instruction
(
migraphx
::
op
::
clip
{
127.0
f
,
-
128.0
f
},
ra
);
auto
qa
=
p
.
add_instruction
(
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int8_type
},
ca
);
// quantize parameter b to int8 type
auto
insert_loc
=
std
::
next
(
pb
);
...
...
@@ -108,10 +108,12 @@ TEST_CASE(dot_large_alpha_beta_float)
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
pb
);
auto
rb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
round
{},
mb
);
auto
cb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
clip
{
127.0
f
,
-
128.0
f
},
rb
);
auto
qb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int8_type
},
cb
);
auto
qb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int8_type
},
cb
);
// quantize parameter b to int32 type
auto
qc
=
p
.
insert_instruction
(
std
::
next
(
pc
),
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int32_type
},
pc
);
auto
qc
=
p
.
insert_instruction
(
std
::
next
(
pc
),
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int32_type
},
pc
);
auto
qdot
=
p
.
add_instruction
(
migraphx
::
op
::
quant_dot
{
2000
,
51
},
qa
,
qb
,
qc
);
p
.
add_instruction
(
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
qdot
);
...
...
@@ -121,7 +123,8 @@ TEST_CASE(dot_large_alpha_beta_float)
auto
p
=
create_program
();
const
std
::
vector
<
std
::
pair
<
float
,
float
>>&
quant_params
{{
0.1
f
,
1.0
f
},
{
0.1
f
,
0.0
f
},
{
0.1
f
,
100.0
f
}};
const
std
::
vector
<
std
::
pair
<
float
,
float
>>&
quant_params
{
{
0.1
f
,
1.0
f
},
{
0.1
f
,
0.0
f
},
{
0.1
f
,
100.0
f
}};
// default scale 64.0f is used for all args
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
...
...
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