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
377021cd
Commit
377021cd
authored
Aug 30, 2019
by
Shucai Xiao
Browse files
clang format
parent
343c4cac
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
27 deletions
+31
-27
test/quantization.cpp
test/quantization.cpp
+31
-27
No files found.
test/quantization.cpp
View file @
377021cd
...
@@ -297,7 +297,8 @@ TEST_CASE(dot_float)
...
@@ -297,7 +297,8 @@ TEST_CASE(dot_float)
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int8_type
},
cb
);
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
int8_type
},
cb
);
// quantize parameter c to int32 type
// quantize parameter c 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
{
1
,
0
},
qa
,
qb
);
auto
qdot
=
p
.
add_instruction
(
migraphx
::
op
::
quant_dot
{
1
,
0
},
qa
,
qb
);
auto
fdot
=
p
.
add_instruction
(
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
qdot
);
auto
fdot
=
p
.
add_instruction
(
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
qdot
);
...
@@ -353,7 +354,8 @@ TEST_CASE(dot_double_2args)
...
@@ -353,7 +354,8 @@ TEST_CASE(dot_double_2args)
// quantize parameter b to int8 type
// quantize parameter b to int8 type
auto
insert_loc
=
std
::
next
(
pb
);
auto
insert_loc
=
std
::
next
(
pb
);
auto
fpb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
pb
);
auto
fpb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
pb
);
std
::
vector
<
float
>
vfb
(
sb
.
elements
(),
0.1
f
);
std
::
vector
<
float
>
vfb
(
sb
.
elements
(),
0.1
f
);
auto
fb
=
p
.
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
sb
.
lens
()},
vfb
));
auto
fb
=
p
.
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
sb
.
lens
()},
vfb
));
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
fpb
);
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
fpb
);
...
@@ -373,8 +375,7 @@ TEST_CASE(dot_double_2args)
...
@@ -373,8 +375,7 @@ TEST_CASE(dot_double_2args)
};
};
auto
p
=
create_program
();
auto
p
=
create_program
();
const
std
::
vector
<
std
::
pair
<
float
,
float
>>&
quant_params
{
const
std
::
vector
<
std
::
pair
<
float
,
float
>>&
quant_params
{{
0.1
f
,
0.0
f
},
{
0.1
f
,
0.0
f
}};
{
0.1
f
,
0.0
f
},
{
0.1
f
,
0.0
f
}};
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
auto
qp
=
create_int8_quantized_prog
();
auto
qp
=
create_int8_quantized_prog
();
...
@@ -488,7 +489,8 @@ TEST_CASE(dot_large_alpha_beta_int32)
...
@@ -488,7 +489,8 @@ TEST_CASE(dot_large_alpha_beta_int32)
auto
insert_loc
=
std
::
next
(
pb
);
auto
insert_loc
=
std
::
next
(
pb
);
std
::
vector
<
float
>
vfb
(
sb
.
elements
(),
0.1
f
);
std
::
vector
<
float
>
vfb
(
sb
.
elements
(),
0.1
f
);
auto
fb
=
p
.
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
sb
.
lens
()},
vfb
));
auto
fb
=
p
.
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
sb
.
lens
()},
vfb
));
auto
conv_b
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
pb
);
auto
conv_b
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
pb
);
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
conv_b
);
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
conv_b
);
auto
rb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
round
{},
mb
);
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
cb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
clip
{
127.0
f
,
-
128.0
f
},
rb
);
...
@@ -501,14 +503,14 @@ TEST_CASE(dot_large_alpha_beta_int32)
...
@@ -501,14 +503,14 @@ TEST_CASE(dot_large_alpha_beta_int32)
};
};
auto
p
=
create_program
();
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
}};
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
auto
qp
=
create_int8_quantized_prog
();
auto
qp
=
create_int8_quantized_prog
();
EXPECT
(
p
==
qp
);
EXPECT
(
p
==
qp
);
}
}
TEST_CASE
(
dot_int32
)
TEST_CASE
(
dot_int32
)
{
{
auto
create_program
=
[]
{
auto
create_program
=
[]
{
...
@@ -551,7 +553,8 @@ TEST_CASE(dot_int32)
...
@@ -551,7 +553,8 @@ TEST_CASE(dot_int32)
auto
insert_loc
=
std
::
next
(
pb
);
auto
insert_loc
=
std
::
next
(
pb
);
std
::
vector
<
float
>
vfb
(
sb
.
elements
(),
0.1
f
);
std
::
vector
<
float
>
vfb
(
sb
.
elements
(),
0.1
f
);
auto
fb
=
p
.
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
sb
.
lens
()},
vfb
));
auto
fb
=
p
.
add_literal
(
migraphx
::
literal
({
migraphx
::
shape
::
float_type
,
sb
.
lens
()},
vfb
));
auto
conv_b
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
pb
);
auto
conv_b
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
convert
{
migraphx
::
shape
::
float_type
},
pb
);
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
conv_b
);
auto
mb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
mul
{},
fb
,
conv_b
);
auto
rb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
round
{},
mb
);
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
cb
=
p
.
insert_instruction
(
insert_loc
,
migraphx
::
op
::
clip
{
127.0
f
,
-
128.0
f
},
rb
);
...
@@ -574,7 +577,8 @@ TEST_CASE(dot_int32)
...
@@ -574,7 +577,8 @@ TEST_CASE(dot_int32)
};
};
auto
p
=
create_program
();
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
}};
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
migraphx
::
quantize_int8
(
p
,
{
"dot"
},
quant_params
);
auto
qp
=
create_int8_quantized_prog
();
auto
qp
=
create_int8_quantized_prog
();
...
...
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