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
648f0685
Unverified
Commit
648f0685
authored
Oct 12, 2023
by
Charlie Lin
Committed by
GitHub
Oct 12, 2023
Browse files
fp16 change default tolerances for driver verify (#2310)
parent
50c5984a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
4 deletions
+38
-4
src/driver/main.cpp
src/driver/main.cpp
+38
-4
No files found.
src/driver/main.cpp
View file @
648f0685
...
...
@@ -540,17 +540,20 @@ struct params : command<params>
struct
verify
:
command
<
verify
>
{
compiler
c
;
migraphx
::
verify
::
tolerance
tols
;
// Set to -1. as nonsense initial value
double
rms_tol
=
-
1.0
;
double
atol
=
-
1.0
;
double
rtol
=
-
1.0
;
bool
per_instruction
=
false
;
bool
reduce
=
false
;
void
parse
(
argument_parser
&
ap
)
{
c
.
parse
(
ap
);
ap
(
tols
.
rms_tol
,
{
"--rms-tol"
},
ap
.
help
(
"Tolerance for the RMS error (Default: 0.001)"
));
ap
(
tols
.
atol
,
ap
(
rms_tol
,
{
"--rms-tol"
},
ap
.
help
(
"Tolerance for the RMS error (Default: 0.001)"
));
ap
(
atol
,
{
"--atol"
},
ap
.
help
(
"Tolerance for the elementwise absolute difference (Default: 0.001)"
));
ap
(
tols
.
rtol
,
ap
(
rtol
,
{
"--rtol"
},
ap
.
help
(
"Tolerance for the elementwise relative difference (Default: 0.001)"
));
ap
(
per_instruction
,
...
...
@@ -569,11 +572,42 @@ struct verify : command<verify>
auto
t
=
c
.
ct
.
get_target
();
auto
m
=
c
.
parameters
.
generate
(
p
,
t
,
true
,
c
.
l
.
batch
);
// TODO remove this and make the driver able to figure out datatype most used in the model
// then set the tolerances appropriately. Need to check here because c.to_fp16 only set
// after argument_parser.parse() is run. This code is complicated because there's not a
// good way to change the default tolerances after reading `--fp16` but before reading
// `--rms-tol`, `--atol`, and `--rtol`.
migraphx
::
verify
::
tolerance
tols
{};
if
(
c
.
to_fp16
)
{
tols
=
migraphx
::
verify
::
tolerance
{
8e-2
,
4e-2
,
4e-2
};
}
if
(
not
float_equal
(
this
->
rms_tol
,
-
1.0
))
{
tols
.
rms_tol
=
this
->
rms_tol
;
}
if
(
not
float_equal
(
this
->
atol
,
-
1.0
))
{
tols
.
atol
=
this
->
atol
;
}
if
(
not
float_equal
(
this
->
rtol
,
-
1.0
))
{
tols
.
rtol
=
this
->
rtol
;
}
std
::
cout
<<
"rms_tol: "
<<
tols
.
rms_tol
<<
std
::
endl
;
std
::
cout
<<
"atol: "
<<
tols
.
atol
<<
std
::
endl
;
std
::
cout
<<
"rtol: "
<<
tols
.
rtol
<<
std
::
endl
;
auto
quantize
=
precision
::
fp32
;
if
(
c
.
to_fp16
)
{
quantize
=
precision
::
fp16
;
}
if
(
c
.
to_int8
)
{
quantize
=
precision
::
int8
;
}
if
(
per_instruction
)
{
...
...
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