Commit cf68ece6 authored by charlie's avatar charlie
Browse files

Fix parse bug

parent f73162a7
...@@ -536,23 +536,20 @@ struct params : command<params> ...@@ -536,23 +536,20 @@ struct params : command<params>
struct verify : command<verify> struct verify : command<verify>
{ {
compiler c; compiler c;
migraphx::verify::tolerance tols; // Set to -1. as nonsense initial value
double rms_tol = -1.;
double atol = -1.;
double rtol = -1.;
bool per_instruction = false; bool per_instruction = false;
bool reduce = false; bool reduce = false;
void parse(argument_parser& ap) void parse(argument_parser& ap)
{ {
c.parse(ap); c.parse(ap);
//TODO remove this and make the driver able to figure out datatype most used in the model ap(rms_tol, {"--rms-tol"}, ap.help("Tolerance for the RMS error (Default: 0.001)"));
// then set the tolerances appropriately ap(atol,
if(c.to_fp16)
{
tols = migraphx::verify::tolerance{8e-2, 4e-2, 4e-2};
}
ap(tols.rms_tol, {"--rms-tol"}, ap.help("Tolerance for the RMS error (Default: 0.001)"));
ap(tols.atol,
{"--atol"}, {"--atol"},
ap.help("Tolerance for the elementwise absolute difference (Default: 0.001)")); ap.help("Tolerance for the elementwise absolute difference (Default: 0.001)"));
ap(tols.rtol, ap(rtol,
{"--rtol"}, {"--rtol"},
ap.help("Tolerance for the elementwise relative difference (Default: 0.001)")); ap.help("Tolerance for the elementwise relative difference (Default: 0.001)"));
ap(per_instruction, ap(per_instruction,
...@@ -571,9 +568,38 @@ struct verify : command<verify> ...@@ -571,9 +568,38 @@ struct verify : command<verify>
auto t = c.ct.get_target(); auto t = c.ct.get_target();
auto m = c.parameters.generate(p, t, true, c.l.batch); 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};
}
auto dbl_comp = [&](auto a, auto b){
return std::abs(a - b) <= std::numeric_limits<double>::epsilon();
};
if(not dbl_comp(this->rms_tol, -1.))
{
tols.rms_tol = this->rms_tol;
}
if(not dbl_comp(this->atol, -1.))
{
tols.atol = this->atol;
}
if(not dbl_comp(this->rtol, -1.))
{
tols.rtol = this->rtol;
}
auto quantize = precision::fp32; auto quantize = precision::fp32;
if(c.to_fp16) if(c.to_fp16)
{
quantize = precision::fp16; quantize = precision::fp16;
}
if(c.to_int8) if(c.to_int8)
quantize = precision::int8; quantize = precision::int8;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment