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
32c48cfe
"...composable_kernel_rocm.git" did not exist on "70c74b0aa32b89a9aa5a18378962c6647ec7715b"
Commit
32c48cfe
authored
Jul 15, 2019
by
Shucai Xiao
Browse files
change the int8 quantization parameter
parent
0bd9c447
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
+7
-6
src/include/migraphx/program.hpp
src/include/migraphx/program.hpp
+1
-1
src/program.cpp
src/program.cpp
+1
-0
src/quantization.cpp
src/quantization.cpp
+5
-5
No files found.
src/include/migraphx/program.hpp
View file @
32c48cfe
...
...
@@ -126,7 +126,7 @@ struct program
friend
bool
operator
==
(
const
program
&
x
,
const
program
&
y
);
friend
bool
operator
!=
(
const
program
&
x
,
const
program
&
y
)
{
return
!
(
x
==
y
);
}
std
::
vector
<
std
::
pair
<
float
,
float
>>
int8_quant_params
;
std
::
shared_ptr
<
std
::
vector
<
std
::
pair
<
float
,
float
>>
>
int8_quant_params
=
std
::
make_shared
<
std
::
vector
<
std
::
pair
<
float
,
float
>>>
()
;
private:
void
assign
(
const
program
&
p
);
...
...
src/program.cpp
View file @
32c48cfe
...
...
@@ -113,6 +113,7 @@ void program::assign(const program& p)
impl
->
instructions
.
clear
();
}
impl
->
ctx
=
p
.
impl
->
ctx
;
int8_quant_params
=
p
.
int8_quant_params
;
std
::
unordered_map
<
instruction_ref
,
instruction_ref
>
ins_map
;
for
(
auto
ins
:
iterator_for
(
p
))
...
...
src/quantization.cpp
View file @
32c48cfe
...
...
@@ -324,13 +324,13 @@ void quantize_int8(program& prog,
void
quantize_int8
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
)
{
quantize_int8
(
prog
,
ins_names
,
prog
.
int8_quant_params
);
quantize_int8
(
prog
,
ins_names
,
*
prog
.
int8_quant_params
);
}
void
quantize_int8
(
program
&
prog
)
{
std
::
vector
<
std
::
string
>
ins_names
=
{
"dot"
,
"convolution"
};
quantize_int8
(
prog
,
ins_names
,
prog
.
int8_quant_params
);
quantize_int8
(
prog
,
ins_names
);
}
// For the input of each input argument, we need to insert a
...
...
@@ -379,7 +379,7 @@ void capture_arguments(program& prog,
}
// set one pair of parameter for each argument
prog
.
int8_quant_params
.
resize
(
num_quant_params
,
std
::
make_pair
(
-
1.0
f
,
-
1.0
f
));
prog
.
int8_quant_params
->
resize
(
num_quant_params
,
std
::
make_pair
(
-
1.0
f
,
-
1.0
f
));
}
void
capture_arguments
(
program
&
prog
,
const
std
::
vector
<
std
::
string
>&
ins_names
)
...
...
@@ -394,9 +394,9 @@ void capture_arguments(program& prog, const std::vector<std::string>& ins_names)
auto
max_val
=
*
std
::
max_element
(
vec_val
.
begin
(),
vec_val
.
end
());
auto
min_val
=
*
std
::
min_element
(
vec_val
.
begin
(),
vec_val
.
end
());
auto
max_abs
=
std
::
max
(
std
::
fabs
(
max_val
),
std
::
fabs
(
min_val
));
param_pair
.
first
=
127.0
f
/
max_abs
;
prog
.
int8_quant_params
[
ins_index
]
=
param_pair
;
param_pair
.
first
=
127.0
f
/
max_abs
;
(
*
prog
.
int8_quant_params
)[
ins_index
]
=
param_pair
;
};
capture_arguments
(
prog
,
ins_names
,
calc_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